Copy rows from one table to another, ignoring duplicates

前端 未结 9 1405
半阙折子戏
半阙折子戏 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条回答
  •  忘掉有多难
    2020-11-27 14:33

    Something like this?:

    INSERT INTO destTable
    SELECT s.* FROM srcTable s
    LEFT JOIN destTable d ON d.Key1 = s.Key1 AND d.Key2 = s.Key2 AND...
    WHERE d.Key1 IS NULL
    

提交回复
热议问题