Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update a single column of a table of data from a backup

Tags:

sql

crash

backup

All the data in a column of a table of members have been erased, but I made a backup of the table a few weeks ago.

So I need to replace only the data in this column by the old column in the backup of my table.

The problem is that I do not know how I should proceed to do so.

Have you been confronted by this problem and can you explain it to me

like image 627
user938609 Avatar asked Jan 30 '12 18:01

user938609


1 Answers

  1. Restore the backup of your table as a temporary table.
  2. Use a UPDATE statement with select to update your members table

Which one of these steps are you having difficulty with?

Here is how I would write the SQL to update my members table from a "members_temp" table

 UPDATE members SET name=(select name from members_temp where members.id = members_temp.id)
like image 62
filype Avatar answered Sep 25 '22 19:09

filype