Lists and ranges: IN and BETWEEN
Stage 2: Filtering · Lesson 7 of 17 · 4 min read · free, interactive
IN (...) is a short way to write many ORs on the same column:
SELECT name, country FROM players WHERE country IN ('VN', 'JP');
BETWEEN a AND b matches a range and includes both ends:
SELECT name, level FROM players WHERE level BETWEEN 7 AND 10;
SELECT id, bought_at FROM purchases WHERE bought_at BETWEEN '2026-11-01' AND '2026-11-30';
Tip: NOT IN and NOT BETWEEN work too. Careful: NOT IN a list that contains NULL matches nothing.
Practice
Each answer runs in your browser and is checked on hidden data.
- Fill in the blanks: Return the
nameandcountryof players from Finland (FI), the Netherlands (NL) or Germany (DE). Row order does not matter. - Write the query: Return the
idandbought_atof purchases made in October 2026 (1st to 31st). Row order does not matter. - Find the bug: Return the
nameandlevelof players with a level from 4 to 9, inclusive. Row order does not matter.
Previous: AND, OR and NOT · Next: Text patterns with LIKE · All lessons