How to exclude rows that don't join with another table?

前端 未结 7 805
心在旅途
心在旅途 2020-11-30 16:48

I have two tables, one has primary key other has it as a foreign key.

I want to pull data from the primary table, only if the secondary table does not

7条回答
  •  感动是毒
    2020-11-30 17:13

    alt text

    SELECT  
    FROM Table_A A
    LEFT JOIN Table_B B
    ON A.Key = B.Key
    WHERE B.Key IS NULL
    

    Full image of join alt text

    From aticle : http://www.codeproject.com/KB/database/Visual_SQL_Joins.aspx

提交回复
热议问题