How can I check for duplicates before inserting into a table when inserting by select

后端 未结 4 1920
时光说笑
时光说笑 2021-02-02 02:28

How can I check for duplicates before inserting into a table when inserting by select:

insert into table1
select col1, col2 
from table2

I need

4条回答
  •  礼貌的吻别
    2021-02-02 03:01

    You can simply add IGNORE into your insert statement.

    e.g

    INSERT IGNORE INTO table1
    SELECT col1, col2 
    FROM table2
    

    This is discussed here

提交回复
热议问题