其他分享
首页 > 其他分享> > [LeetCode] #183 从不订购的客户

[LeetCode] #183 从不订购的客户

作者:互联网

某网站包含两个表,Customers 表和 Orders 表。编写一个 SQL 查询,找出所有从不订购任何东西的客户。

Customers 表:

Orders 表:

例如给定上述表格,你的查询应返回:

 

左外连接

SELECT Name AS Customers FROM Customers a left JOIN Orders b ON a.Id = b.CustomerId WHERE b.Id IS NULL;

嵌套子查询

SELECT Name AS Customers FROM Customers WHERE Id NOT IN(SELECT Customerid FROM Orders);

知识点:

总结:

 

标签:Customers,Name,订购,Orders,183,LeetCode,查询,Id,SELECT
来源: https://www.cnblogs.com/jpppp/p/15214306.html