LeetCode - 584. Find Customer Referee (MySQL)

조민수·2024년 6월 3일
0

LeetCode

목록 보기
7/61

Easy, SQL - NULL 처리

RunTime : 963 ms


문제

Find the names of the customer that are not referred by the customer with id = 2.

Return the result table in any order.

The result format is in the following example.


풀이

  • 처음엔 단순히 referee_id != 2 이거만 했는데, NULL처리가 안되어 틀렸다.
  • NULL이 포함되어 있을 땐, NULL처리도 확실히 해줘야 한다.
SELECT name FROM Customer
WHERE referee_id IS NULL OR referee_id != 2
profile
사람을 좋아하는 Front-End 개발자

0개의 댓글