Find Customer Referee Problem
Description
LeetCode Problem 584.
Given a table customer holding customers information and the referee.
1
2
3
4
5
6
7
8
9
10
+------+------+-----------+
| id | name | referee_id|
+------+------+-----------+
| 1 | Will | NULL |
| 2 | Jane | NULL |
| 3 | Alex | 2 |
| 4 | Bill | NULL |
| 5 | Zack | 1 |
| 6 | Mark | 2 |
+------+------+-----------+
Write a query to return the list of customers NOT referred by the person with id ‘2’.
For the sample data above, the result is:
1
2
3
4
5
6
7
8
+------+
| name |
+------+
| Will |
| Jane |
| Bill |
| Zack |
+------+
MySQL Solution
1
2
3
select name
from customer
where referee_id != '2' or referee_id is null
LeetCode Database - Easy
LeetCode 175
LeetCode 176
LeetCode 181
LeetCode 182
LeetCode 183
LeetCode 196
LeetCode 197
LeetCode 511
LeetCode 512
LeetCode 577
LeetCode 584
LeetCode 586
LeetCode 595
LeetCode 596
LeetCode 597
LeetCode 603
LeetCode 607
LeetCode 610
LeetCode 613
LeetCode 619
LeetCode 620
LeetCode 627
More LeetCode Database
MySQL Tutorials