MySQL possible to update multiple rows with different where clause, single query
Is is possible to have one query update multiple columns with different where clauses for example, can you combine this?
update tblTest set price = '5000'开发者_如何学编程 where id = '2'
update tblTest set price = '3000' where id = '3'
update tblTest set price = '4000' where id = '4'
how would you combine those 3 queries to one query?
I think it's
UPDATE `tblTest` SET `price` = CASE `Id`
WHEN 2 THEN 5000
WHEN 3 THEN 3000
WHEN 4 THEN 4000
END CASE;
精彩评论