*LeetCode Mysql 查找从来不购买的客户

Customers:

Id Name
1 Joe
2 Henry
3 Sam
4 Max

Orders:

Id CustomerId
1 3
2 1

Q:

  • 根据Customers 和 Orders 表查找出从来没有发生购买行为的人

A:

select customers.name as "Customers"
from customers
where customers.id not in (
    select customerid from orders
);

猜你喜欢

转载自blog.csdn.net/weixin_44355591/article/details/106003299
今日推荐