On Tue, Jul 8, 2008 at 12:22 AM, Lyle <[EMAIL PROTECTED]> wrote:
> How can I restore from the backup so that these table rows are merged
> rather than replaced?
>
> For example:-
> The backup has:-
> user1 (ID), 1000 (totalamount)
>
> new database has
> user1 (ID), 100 (totalamount)
>
> I want to restore the backup and get:-
> user1, 1100
>

Hi Lyle,

You could try the 'INSERT ... ON DUPLICATE KEY UPDATE' syntax

http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

Something like:

insert into new_table  select * from old_table on duplicate key update
new_table.totalamount = new_table.totalamount + old_table.totalamount;

Or if old_table doesn't have any unique rows, or you don't want to add
them to new_table just use a multiple table update

update new_table  set new_table.totalamount = new_table.totalamount +
old_table.totalamount where new_table.id = old_table.id;

Whatever you try, have a backup and do it locally first :-)

Mark.
_______________________________________________
BristolBathPM mailing list
[email protected]
http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm

Reply via email to