Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a database in which there is one table where one column has invalid data.

I also have a backup of said database of a few days before. In that backup, that column still has the valid data. But other tables in that database are already incredibly outdated.

So, a full rollback to that backup is not an option. Rather, I would like to only import that single, corrupted column from the backup into the current database.

The live database has also accumulated a few new, valid rows in that table. Obviously, we would like those to be preserved.

I can't think of a way that doesn't involve heavy, manual editing. Can this be automated?

share|improve this question
Is there a single row whose single column needs to be fixed, or are you replacing the said column in every row ??? – RolandoMySQLDBA Jul 31 '12 at 22:52
@RolandoMySQLDBA: In every row. But the live database may have more valid and new rows. Thanks for noticing. – Oliver Salzburg Jul 31 '12 at 23:02
up vote 6 down vote accepted

Yes you can. Import that data from the backup into a temporary table and do something like this:

UPDATE target_schema.target_table tt
JOIN source_schema.source_table ss ON tt.t_id = ss.s_id
SET tt.target_column = ss.source_column;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.