id name status
1 abc 1
2 pqr 0
conditional update for same column
I want query like
update table set status = 1 Where id = 2 AND set status = 0 Where id != 2
is it possible to do with single query ?
UPDATE <table>
SET status = (CASE WHEN id = 2 THEN 1
ELSE 0 END)
update table set status = CASE id WHEN 2 THEN 1 ELSE 0 END