Copy rows from one table to another, ignoring duplicates

前端 未结 9 1407
半阙折子戏
半阙折子戏 2020-11-27 13:44

I have 2 tables (srcTable1 & destTable) that have identical schemas. I am trying to copy all rows from srcTable to destTable and ignore the duplicates. I thought I could

9条回答
  •  猫巷女王i
    2020-11-27 14:45

    insert into tbl2
    select field1,field2,... from tbl1
    where not exists 
        ( 
            select field1,field2,... 
            from person2
            where (tbl1.field1=tbl2.field1 and
            tbl1.field2=tbl2.field2 and .....)
        )
    

提交回复
热议问题