问题描述:

I have two tables with the same columns (ID, name, etc.). But it appears that I have duplicate rows from both of them. I am supposed to move/copy the rows from table1 to table2 but it won't let me since I have a lot of duplicate rows and I can't get the right syntax to merge them properly.

I am using phpMyAdmin, btw.

Can someone help, please? Thank you in advance.

网友答案:

If you would simply like to delete the rows which are duplicates, do a JOIN like this:

DELETE table1.*
FROM table1
INNER JOIN table2 ON table2.Id = table1.Id
网友答案:

Please see the INSERT IGNORE & ON DUPLICATE KEY UPDATE from http://dev.mysql.com/doc/refman/5.5/en/insert.html

相关阅读:
Top