mysql复制到另一个只有新的记录

时间:2013-06-19 09:56:28

标签: mysql mysqli mysqldump mysql-workbench mysql-error-1064

我有2张桌子:

lang temp:

sku|postid|fi|en|ru (15000 records / included 200 full_products records)

full_products:

sku|postid|fi|en|ru|xx|zzz|aaaa|bbb (200 records)

postid是单一的,它不能相同。

我只需要将lang temp中的新记录复制到full_products。怎么可能是查询?

1 个答案:

答案 0 :(得分:0)

尝试

INSERT INTO full_products (sku,postid,fi,en,ru)
SELECT sku,postid,fi,en,ru
  FROM lang_temp l
 WHERE NOT EXISTS 
 (
   SELECT 1 
     FROM full_products
    WHERE post_id = l.post_id
      AND sku = l.sku
 )