1.题目

【LeetCode-Database183】从不订购的客户(not in)_mysql


【LeetCode-Database183】从不订购的客户(not in)_mysql_02

2.思路

找出没有订购东西的客户。
用not in语句即可:找customers表中id列中,除了orders表的customerid列的顾客。

3.代码

# Write your MySQL query statement below
select customers.name as 'Customers'
from customers
where customers.id not in(
select customerid from orders
);