我的问题是,是否有办法进行条件更新,例如
if existence = true
then update market set exitdate = now(), existence = false
else then update market set exitdate = null, existence = true
对于我想要的更多内容,我找不到与我的代码类似的内容。
答案 0 :(得分:0)
我用下一个代码解决了......
UPDATE market
SET exitdate = CASE WHEN existence = true AND boxnumm = xxxx then now() else null END,
existence = CASE WHEN exitdate <> null AND boxnumm = xxxx then false else true END
WHERE boxnumm = xxxx
;