Lim Seunghyun Space

[Leetcode] 183. Customers Who Never Order 본문

SQL/SQL 문제

[Leetcode] 183. Customers Who Never Order

Lim Seung Hyun 2022. 3. 23. 15:25

문제 출처

 

Customers Who Never Order - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

 

나의 풀이 (not in 사용)

select c.name as Customers
from Customers as c
where c.id not in (select distinct(customerId) from Orders)

 

나의 풀이(not exists 사용)

select c.name as Customers
from Customers as c
where not exists (select * from Orders as o where c.id = o.customerId)
728x90