【SQL】LeetCode-Customers Who Never Order
作者:互联网
LeetCode 183:Customers Who Never Order
【Description】
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything.
Table: Customers.
Table: Orders.
Using the above tables as example, return the following:
【Solution】
Personal solution:
select name as customers
from customers as c
left join orders as o
on c.id =o.customerid
where o.id is null
Reference solution:
select customers.name as 'Customers'
from customers
where customers.id not in
(
select customerid from orders
);
标签:Customers,Never,Who,customers,customerid,id,select 来源: https://blog.csdn.net/qq_41515531/article/details/112677062