Updating multiple rows in mysql

For multiple-table updates, there is no guarantee that assignments are carried out in any particular order.

If you set a column to the value it currently has, My SQL notices this and does not update it.

This seems to better fit the scenario you describe, is much easier to read, and avoids those difficult-to-untangle multiple conditions.I’ve had to figure this out on my own twice now, so I guess it’s time to document it.It is possible, and fairly easy, to update multiple rows of a My SQL table at the same time, with different values for each row.Here’s where the multiple updates in a single query trick comes into play.You can just create a long query to update the database and run it only once instead of hundreds of small queries (which in case you didn’t figure it out, would bring your database to its knees in many cases).

Leave a Reply