Reputation: 3514
I have a serious issue with a mySQL database, but luckily I have backups. I just don't know how to restore that affected part without modifying the others.
I have rows with:
product | name | country
The product
and name
should stay as they are, but for each of the rows I have to restore the country
part as they are in the .sql backup file. What's the easiest way to do that?
Something like
`UPDATE my_table SET country="123,123,134" WHERE product="9876"
`UPDATE my_table SET country="482,482,593" WHERE product="4543"
etc.
The country
value is different for each product
.
Thanks so much for any help!
Upvotes: 0
Views: 851
Reputation: 25351
I assume there is a primary key in your table that you just did not mention, so it is actually:
my_table
ID | product | name | country
Restore the table from your backup under another name, let's say my_backup_table
. Then use the following SQL:
UPDATE my_table SET my_table.country = my_backup_table.country
WHERE my_table.ID = my_backup_table.ID
Upvotes: 1