2020-06-14
阅读量:
926
MySQL面试题:查找出从不订购的客户

来源:力扣网
解题思路:如果我们有一份曾经订购过的客户名单,就很容易知道谁从未订购过,然后用not in 查询不在此列表中的客户
方法一:利用子查询
select customers.name as 'Customers'
from customers
where customers.id not in
(
select customerid from orders
);
方法二:利用左反连接
select name from customers left join orders on customers.id=orders.customerid
where orders.id is null;






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论