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

后端 未结 4 1912
时光说笑
时光说笑 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 02:55

    insert into table1
    select col1, col2 
    from table2 
    where table2.col1 not in (select col1 from table1)
    

提交回复
热议问题