3 ms·
One of the things I prefer to do is to only write UPDATE statements that update a single row. For example instead of: UPDATE line_items SET quantity = 1 WHERE
by gav 14y ago
One of the things I prefer to do is to only write UPDATE statements that update a single row. For example instead of:
UPDATE line_items SET quantity = 1 WHERE quantity < 1;
I'd script the following updates:
UPDATE line_items SET quantity = 1 WHERE quantity < 1 AND id = 123;
For each of the individual rows that needed to be changed. Then I have a check that I'm really updating just the rows I expect, this is especially important to me where the UPDATE involves joins, as I find this is the trickiest to get right.