Tips
NULL values
+------+------+-----------+
| id | name | referee_id|
+------+------+-----------+
| 1 | Will | NULL |
| 2 | Jane | NULL |
| 3 | Alex | 2 |
| 4 | Bill | NULL |
| 5 | Zack | 1 |
| 6 | Mark | 2 |
+------+------+-----------+
# this code doesn't select the NULL values
select name
from customer
where referee_id != 2;
# this code does select the NULL values
select name
from customer
where referee_id is NULL or referee_id != 2;JOIN vs Subquery
Aggregate Function
Nth largest/smallest
IF() vs CASE
COALESCE() vs IFNULL()
Replace
Union vs OR
Pay special attention on corner cases:
Last updated