[LeetCode] SQL 50 / MYSQL / 584. Find Customer Referee
2023. 11. 12. 21:49ㆍCoding/LeetCode-SQL
문제 링크
https://leetcode.com/problems/find-customer-referee/description/
문제
소스코드
# Write your MySQL query statement below
SELECT name
FROM Customer
WHERE referee_id != 2 OR referee_id is NULL;
!= 를 이용해서 id 가 2와 다르다는 것을 WHERE 조건절에 나타낸다. 2가 아닌 모든 값을 나타내야 하는데, 이때 IS NULL을 쓰지 않으면 NULL 값은 제외되어서 출력이 된다. 따라서, IS NULL 조건을 같이 포함시켜준다.
'Coding > LeetCode-SQL' 카테고리의 다른 글
[LeetCode] SQL 50 / Oracle / 1378. Replace Employee ID With The Unique Identifier (0) | 2024.01.06 |
---|---|
[LeetCode] SQL 50 / MYSQL / 1683. Invalid Tweets (0) | 2023.11.12 |
[LeetCode] SQL 50 / MYSQL / 1148. Article View I (0) | 2023.11.12 |
[LeetCode] SQL 50 / MYSQL / 595.Big Countries (0) | 2023.11.12 |
[LeetCode] SQL 50 / MYSQL / 1757.Recyclable and Low Fat Products (0) | 2023.11.12 |