Updating multiple rows in mysql

The resultant query, to all of you holding your breath, will look something like this: UPDATE `table` SET `column1` = CASE WHEN `id`='1034786' THEN '0' WHEN `id`='1037099' THEN '0' WHEN `id`='1034789' THEN '3' ELSE `column1` END, `column2` = CASE WHEN `id`='1034786' THEN NULL WHEN `id`='1037099' THEN '1034789' WHEN `id`='1034789' THEN '1034789' ELSE `column2` END, `column3` = CASE WHEN `id`='1034786' THEN 'Text One' WHEN `id`='1037099' THEN 'Text Two' WHEN `id`='1034789' THEN 'Text Three' ELSE `column3` END WHERE `id`='1034786' OR `id`='1037099' OR `id`='1034789' As you can see, for each column to be update we create a CASE statement which updates the column based on a unique ID.

As I said, it’s not as easy as inserting, but if you have ever seen a case or switch statement while programming it should be straight forward.

I hope you ppl understand it more now And again, thanks in advance The above cannot be achieved in single sql statement. Create statement once, set values and execute query for different values.

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.

My SQL allows a more readable way to combine multiple updates into a single query.

This seems to better fit the scenario you describe, is much easier to read, and avoids those difficult-to-untangle multiple conditions.