I need to update a lot of rows, per a user request. It is a site with products.
I could...
- Delete all old rows for that product, then loop through string building a new
INSERT
query. This however will lose all data if theINSERT
fails. - Perform an
UPDATE
through each loop. This loop currently iterates over 8 items, but in the future it may get up to 15. This manyUPDATE
s doesn't sound like too good an idea. - Change DB Schema, and add an
auto_increment
Id to the rows. Then first do aSELECT
, get all old rows ids in a variable, perform oneINSERT
, and then aDELETE WHERE IN SET
.
What is the usual practice here?
Thanks