mysql - Table Recovery Question -


suppose have table following schema:

tableid
field1
field2
.....

i have 2 copies of database (backup , production). on production instance, query accidentally run did following:

update table set field2 = null field1 = 'x'; 

i trying undo query based on data stored in backup instance (where bad update statement not run).

what sql statements need run on backup db retrieve tableid , values of field2? how convert appropriate update statements fix production? there quite few rows impacted query.

i think select erased values backup following query:

select tableid, field2 field1 = 'x'; 

however, i'm @ loss how convert easy update statement. insight (or better ideas) appreciated.

you'll need data update in same database, when select backup field1 = 'x', save temporary table , copy production table.

you'll need sort of primary key between 2 tables -- if don't have that, how know field2 needs updated?

for instance, if table had

field1   field2 x        5 x        9 x        null y        5 

and has

field1   field2 x        null x        null x        null y        5 

and if there other fields, how distinguish proper record x/5 x/9, , more importantly, field2 null before update?

if have sort of primary key, can update table1 (field2) select field2 backuptable table1.field1 = backuptable


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -