0

My question is if there is a way to do a conditional update for example

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

For more that I look for, I can't find something similar to my code.

R. Nuñez
  • 15
  • 6

1 Answers1

0

I resolved it with the next code...

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
;
R. Nuñez
  • 15
  • 6