BeginnerCoder

Lesson 11 — Filtering with IN and BETWEEN

IN and BETWEEN: shorter conditions

IN (a, b, c) is short for "= a OR = b OR = c". BETWEEN x AND y is short for ">= x AND <= y" — both ends are included. They make WHERE clauses shorter and easier to read.

WHERE city IN ('Almaty', 'Astana')
WHERE price BETWEEN 10 AND 20

Why it matters: filters like "these three categories" or "this price range" are exactly what shop filter panels send to the database.

Want it another way?
Task

Combine two conditions: the category is books or games, and the price is from 10 to 30 (both ends included). Expected: Atlas and Chess.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.