---
# System prepended metadata

title: \#183 Customers Who Never Order
tags: [leetcode, leetcode-easy, sql]

---

# \#183 Customers Who Never Order
## *給定客戶&訂單兩table, 找出從未下過單的客戶*
## Log
 - build 20210417 by syhuang

## join解
 - 因in語法在數據量大的時候會出問題, 另一種left join解
```sql=
select c.Name as Customers
  from Customers c
  left join Orders o on o.CustomerId = c.Id
 where o.Id is null
```

## 初見
 - sql in用法(建議少用)
```sql=
select Name as Customers
  from Customers
 where Id not in(
        select distinct CustomerId
          from Orders)
```
## 備註
 - [in(not in)的限制](https://stackoverflow.com/questions/1069415/limit-on-the-where-col-in-condition)
 - [in/join/exists 3種解法](https://leetcode.com/problems/customers-who-never-order/discuss/53579/Three-accepted-solutions)
## 參考
###### tags: `leetcode`, `leetcode-easy`, `sql`