I do have two table say table1
and table2
both tables have same structure but pk index values are different. so repetation is minimum.
table1 has got 56000 datas
table2 has got 23000 datas
I want merge/import table2
to table1.
there 开发者_如何转开发may be some repetations in PK so I need to ignore that data(dont want to import/rewrite or duplicate) and import rest of the data. I am using phpmyadmin so I want do it through that.
I'm pretty sure you can do:
INSERT IGNORE INTO table1 SELECT * FROM table2;
to ignore duplicate keys.
However, please try it on a third table first ;)
Here's a link: http://dev.mysql.com/doc/refman/5.0/en/insert-select.html
Have you tried using UNION DISTINCT
into another table?
http://dev.mysql.com/doc/refman/5.0/en/union.html
So you could write something like this:
insert into table3
select * from table1
union distinct
select * from table2
Hope that helps.
Sorry if syntax is not spot on - don't use MySQL here in work.
精彩评论