[英]mysql merging two tables if not exist
I want to merge two tables, but not the duplicate entries with similar id field. 我想合并两个表,但不合并具有相似id字段的重复条目。
But I get error after: 但是我得到以下错误:
INSERT INTO table1 (id, name)
SELECT id, name FROM table2 WHERE table2.id NOT_IN (SELECT id FROM table1);
You have to change NOT_IN
in NOT IN
, as this is the correct synthax 您必须在
NOT IN
更改NOT_IN
,因为这是正确的合成器
INSERT INTO table1 (id, name)
SELECT id, name FROM table2 WHERE table2.id NOT IN(SELECT id FROM table1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.