SQL: … WHERE X IN (SELECT Y FROM …)

后端 未结 5 895
Happy的楠姐
Happy的楠姐 2021-02-12 11:30

Is the following the most efficient in SQL to achieve its result:

SELECT * 
  FROM Customers 
 WHERE Customer_ID NOT IN (SELECT Cust_ID FROM SUBSCRIBERS)
         


        
5条回答
  •  不知归路
    2021-02-12 12:08

    Maybe try this

    Select cust.*
    
    From dbo.Customers cust
    Left Join dbo.Subscribers subs on cust.Customer_ID = subs.Customer_ID
    Where subs.Customer_Id Is Null
    

提交回复
热议问题