Lesson 18 of 30
60%
IN and BETWEEN
IN checks a list. BETWEEN checks a range.
Both keep WHERE short and readable.
IN
This is easier than a pile of OR tests.
sql
Result
| name | city |
|---|---|
| Ada | London |
| Lin | Taipei |
| Omar | Cairo |
3 rows
NOT IN
sql
Result
| name | city |
|---|---|
| Sam | Kenya |
| Lin | Taipei |
| Nia | Unknown |
3 rows
BETWEEN
BETWEEN is inclusive. Both ends are kept.
sql
Result
| name | age |
|---|---|
| Ada | 12 |
| Sam | 11 |
| Lin | 13 |
| Omar | 12 |
4 rows
Dates too
sql
Result
| name | added_on |
|---|---|
| Yo-yo | 2026-03-12 |
| Kite | 2026-07-01 |
2 rows
Tip: BETWEEN works for numbers, dates, and text. For text, it uses dictionary order.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.