🔧 Quick Syntax
SELECT column1, column2
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
This is how you tell SQL:
“Show me all the rows where this value falls between X and Y — including both ends.”
It works with numbers, dates, even letters. Super helpful for age ranges, date filters, prices, and more.
🧾 Here’s the Table You’re Working With
Let’s say you’ve got a table called customers
:
id | name | age | city |
---|---|---|---|
1 | Fenn Rask | 22 | Fogtown |
2 | Milo Kresh | 35 | Dustvale |
3 | Sora Dune | 28 | Cloudhill |
4 | Tovi Glint | 41 | Windmere |
5 | Lexa Vohn | 30 | Fogtown |
6 | Kye Trinn | 19 | Dustvale |
✅ Suppose You Want Customers Aged Between 25 and 35
SELECT name, age
FROM customers
WHERE age BETWEEN 25 AND 35;
💡 Output:
Milo Kresh 35
Sora Dune 28
Lexa Vohn 30
SQL gave you all the rows where age
is between 25 and 35, including 25 and 35 themselves.
That’s important — BETWEEN
is inclusive.
✅ You Can Use It with Dates Too
Imagine you had a signup_date
column and you wanted users who signed up this month:
SELECT name, signup_date
FROM customers
WHERE signup_date BETWEEN '2025-04-01' AND '2025-04-30';
This would give you all users who signed up in April 2025 — from the 1st through the 30th. Simple and super readable.
🧃 Recap – What You Learned
BETWEEN x AND y
filters values within a range- It works with numbers, dates, and even text
- Inclusive: includes both
x
andy
- Cleaner than using
>=
and<=
separately