🎯 BETWEEN – Filter Values Within a Range in SQL

🔧 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
1Fenn Rask22Fogtown
2Milo Kresh35Dustvale
3Sora Dune28Cloudhill
4Tovi Glint41Windmere
5Lexa Vohn30Fogtown
6Kye Trinn19Dustvale

✅ 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 and y
  • Cleaner than using >= and <= separately

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top