I am trying to understand how to UPDATE multiple rows with different values and I just don't get it. The solution is everywhere but to me it looks difficult to understand.
For instance, two updates into 1 query:
UPDATE mytable SET fruit='orange', drink='water', food='pizza' WHERE id=1;
UPDATE mytable SET fruit='strawberry', drink='wine', food='fish' WHERE id=2;
I don't understand what the CASE WHEN .. THEN … END works and how to use it.
Wonder if someone could help me on this.
Best Answer
Personally, using
CASE WHEN THEN END
looks clumsy.You could code this using the IF function.
Give it a Try !!!
CAVEAT :
CASE WHEN THEN END
is only handy when dealing with multiple values (more than 2)