Need SQL Query to find Parent records without child records

前端 未结 6 1701
迷失自我
迷失自我 2020-12-08 10:12

I am not at all conversant in SQL so was hoping someone could help me with a query that will find all the records in a parent table for which there are no records in a child

6条回答
  •  粉色の甜心
    2020-12-08 10:46

    You can try NOT IN

    SELECT * FROM ParentTable WHERE ParentID NOT IN (SELECT DISTINCT ParentID FROM ChildTable)
    

提交回复
热议问题