*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
);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章