0

我的问题是,例如,是否有办法进行条件更新

if existence = true 
    then update market set exitdate = now(), existence = false
    else then update market set exitdate = null, existence = true

对于我要寻找的更多内容,我找不到与我的代码类似的东西。

4

1 回答 1

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
;
于 2018-01-10T18:49:51.843 回答