8.5 BETWEEN
Level: 8 | Version: v1.1 | Author: Meptrasoft
Overview
BETWEEN is used to filter values within a range.
The starting and ending values are both included.
SELECT *
FROM employees
WHERE salary BETWEEN 20000 AND 50000;
This returns employees whose salary is:
>= 20000
AND
<= 50000
BETWEEN → Check whether a value falls within a range.

Practice Table
This topic reuses the employees table from 8.1 The WHERE Clause.
| emp_id | emp_name | dept_id | salary |
|---|---|---|---|
| 1 | John Smith | 10 | 45000 |
| 2 | Emma Brown | 20 | 60000 |
| 3 | Samuel Reed | 10 | 32000 |
| 4 | Anderson | 30 | 55000 |
| 5 | Sarah Wilson | 20 | 48000 |
| 6 | Tom Watson | 10 | 51000 |
BETWEEN with Numbers
Find employees whose salary is between 30000 and 50000:
SELECT *
FROM employees
WHERE salary BETWEEN 30000 AND 50000;
This includes salaries of exactly 30000 and 50000.
BETWEEN is inclusive.
BETWEEN with Dates
BETWEEN can also be used with dates.
For example:
SELECT *
FROM employees
WHERE join_date BETWEEN '2026-01-01' AND '2026-06-30';
This selects dates within the specified range, including the boundary dates.
BETWEEN vs Comparison Operators
This:
WHERE salary BETWEEN 30000 AND 50000
is equivalent to:
WHERE salary >= 30000
AND salary <= 50000
BETWEEN is often easier to read when working with ranges.
NOT BETWEEN
NOT BETWEEN can be used to exclude a range.
SELECT *
FROM employees
WHERE salary NOT BETWEEN 30000 AND 50000;
This returns salaries below 30000 or above 50000.
NOT BETWEEN → Outside the specified range.
NULL Values
If the value being tested is NULL, the BETWEEN condition does not evaluate to TRUE.
For example:
salary = NULL
does not match:
WHERE salary BETWEEN 30000 AND 50000
NULL requires separate handling with IS NULL or IS NOT NULL.
Common Beginner Mistakes
| ✗ Mistake | ✓ Correct Understanding |
|---|---|
BETWEEN excludes the boundary values |
Both boundary values are included |
BETWEEN 30000 AND 50000 means only values strictly inside |
30000 and 50000 are included |
BETWEEN works only with numbers |
It can also be used with comparable values such as dates |
BETWEEN changes the stored data |
It only filters query results |
NOT BETWEEN means equal to the boundaries |
It means outside the specified range |
Placement Quick Points
BETWEEN
→ RANGE FILTER
START
→ INCLUDED
END
→ INCLUDED
NOT BETWEEN
→ OUTSIDE THE RANGE
BETWEENfilters values within a range.- The start and end values are included.
BETWEENcan be used with numbers, dates, and other comparable values.NOT BETWEENexcludes the specified range.NULLvalues require separate handling.
Interview Questions
- What is BETWEEN in SQL?
BETWEENfilters values that fall within a specified range.- Is BETWEEN inclusive?
Yes. Both the lower and upper boundary values are included.
- What is the equivalent of BETWEEN?
salary BETWEEN 30000 AND 50000is equivalent to:
salary >= 30000 AND salary <= 50000- Can BETWEEN be used with dates?
Yes.
WHERE join_date BETWEEN '2026-01-01' AND '2026-06-30'- What is NOT BETWEEN?
It selects values outside the specified range.
- Does BETWEEN include NULL?
No. A
NULLvalue does not satisfy aBETWEENcondition.
Practice & Hands-On Exercises
Using the employees table:
- Find employees with salary between
30000and50000:
SELECT * FROM employees WHERE salary BETWEEN 30000 AND 50000;
- Find employees with salary between
40000and60000:
SELECT * FROM employees WHERE salary BETWEEN 40000 AND 60000;
- Find employees whose salary is not between
30000and50000:
SELECT * FROM employees WHERE salary NOT BETWEEN 30000 AND 50000;
- Write the equivalent
>=and<=condition for aBETWEENquery:
SELECT * FROM employees WHERE salary >= 30000 AND salary <= 50000;
- Explain why
BETWEENincludes both boundary values.
💡 Tip: Test your queries using the in-browser interactive runner above.
Key Takeaway
BETWEEN 30000 AND 50000
↓
>= 30000 AND <= 50000
BETWEEN is used to filter values within an inclusive range, including both the starting and ending values.
End of BETWEEN