【发布时间】:2022-12-03 15:37:31
【问题描述】:
我正在尝试修改一列,我想将一些行设置为 true,其他行将它们转换为 false
update products set on_sale=False where status=1 and seller=test;
update products set on_sale=true Where price > 100 and status=1 and seller=test;
上面的工作,但我相信它可以在 1 个查询中完成,比如这样
\\ python syntax for the if condition
update prodcuts set on_sale=(True if price > 100 else False) WHERE status=1 and seller=test
【问题讨论】:
标签: python postgresql