MySQL query for Future :D

select CONCAT("insert into DB1.", table_name, " select * from DB1_BACKUP ", table_name, " ON DUPLICATE KEY UPDATE DB1.", table_name, ".id=DB1_BACKUP.", table_name, ".id;") from information_schema.tables where table_schema='DB1' and table_name regexp "<TABLE NAME>";