Answer the question
In order to leave comments, you need to log in
mysql update multiple update in one query
Hello, I apologize in advance if this question seems childish to someone.
It is required to update 5 records in the same table in different rows.
Ie SET filed=1 where id=1, SET filed=2 where id=12, SET filed='0.5' where id=3…
Described as best I could. I would really appreciate it if you point me in the right direction
Answer the question
In order to leave comments, you need to log in
Your solution is slow. It is more efficient to update 1 field per 1 normal request, without joins.
Or use this option, it's much more efficient than yours:
UPDATE `table` SET `field` = CASE `id`
WHEN val1 THEN data1
WHEN val2 THEN data2
ELSE `field` END
Just be sure not to forget ELSE.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question