SQL query to find record with ID not in another table

后端 未结 6 1636
眼角桃花
眼角桃花 2020-12-02 09:02

I have two tables with binding primary key in database and I desire to find a disjoint set between them. For example,

  • Table1 has columns (ID
6条回答
  •  鱼传尺愫
    2020-12-02 09:19

    Use LEFT JOIN

    SELECT  a.*
    FROM    table1 a
                LEFT JOIN table2 b
                    on a.ID = b.ID
    WHERE   b.id IS NULL
    

提交回复
热议问题