Answer the question
In order to leave comments, you need to log in
How to execute two updates in one, with different conditions?
I have a table and it has a default column, I need a query like this: update the row with the value default = 1 by replacing default with 0 and replace the row with the value id = any number by replacing it with default = 1.
How to do this in one query ?
Answer the question
In order to leave comments, you need to log in
Something like this:
UPDATE tbl
SET default = CASE
WHEN id = любое число THEN 1
WHEN default = 1 THEN 0
ELSE default
END;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question