SQL BETWEEN Operator – Filter a Range of Values with Examples (2026-27)
The SQL BETWEEN operator is used to filter rows where a column value falls within a specified range — including both the lower and upper boundary values. It works with numbers, text (alphabetical order), and dates, and is one of the most commonly used filtering tools in real-world SQL queries. Instead of writing WHERE Salary >= 5000 AND Salary <= 10000, you can write the cleaner, more readable WHERE Salary BETWEEN 5000 AND 10000. In this step-by-step guide you will learn the full BETWEEN syntax, see five real examples — numbers, NOT BETWEEN, text, dates, and BETWEEN with IN — plus a comparison table and the most common mistakes to avoid.
✅ What is the SQL BETWEEN Operator?
✅ The SQL BETWEEN operator is used in a WHERE clause to filter rows within a range.
✅ It is inclusive — both the start value and end value are included in the result.
✅ It works with numbers, text (alphabetical), and dates.
BETWEEN 5000 AND 10000 is cleaner and more readable than writing >= 5000 AND <= 10000 — and gives identical results.
✅ Sample Employees Table used in all examples:-
| ID | Name | Department | Salary | JoinDate |
|---|---|---|---|---|
| 1 | ANNI | IT | 10000 | 2023-03-15 |
| 2 | POOJA | IT | 90000 | 2024-07-01 |
| 3 | RAJ | HR | 5000 | 2022-11-20 |
| 4 | SUJAN | HR | 8000 | 2024-01-10 |
| 5 | MEENA | Sales | 12000 | 2023-06-30 |
✅ SQL BETWEEN Syntax
SELECT column1, column2, ...
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
✅ BETWEEN:- Keyword — placed after the column name in the WHERE clause.
✅ value1:- The lower bound of the range (inclusive).
✅ AND:- Separator between the two range values — required.
✅ value2:- The upper bound of the range (inclusive).
WHERE Salary BETWEEN 5000 AND 10000 is exactly the same as WHERE Salary >= 5000 AND Salary <= 10000. BETWEEN is simply cleaner to read and write.
✅ Example 1 – BETWEEN with Numbers (Salary Range)
Find all employees whose salary is between 5000 and 10000 (both values included).
✅ SELECT Query:-
SELECT * FROM Employees
WHERE Salary BETWEEN 5000 AND 10000;
✅ Result:-
| ID | Name | Department | Salary | JoinDate |
|---|---|---|---|---|
| 1 | ANNI | IT | 10000 | 2023-03-15 |
| 3 | RAJ | HR | 5000 | 2022-11-20 |
| 4 | SUJAN | HR | 8000 | 2024-01-10 |
✅ Example 2 – NOT BETWEEN (Exclude a Range)
Find all employees whose salary is OUTSIDE the range 5000 to 10000.
✅ SELECT Query:-
SELECT * FROM Employees
WHERE Salary NOT BETWEEN 5000 AND 10000;
✅ Result:-
| ID | Name | Department | Salary | JoinDate |
|---|---|---|---|---|
| 2 | POOJA | IT | 90000 | 2024-07-01 |
| 5 | MEENA | Sales | 12000 | 2023-06-30 |
✅ Example 3 – BETWEEN with Text (Alphabetical Range)
Find all employees whose name falls alphabetically between 'ANNI' and 'POOJA'.
✅ SELECT Query:-
SELECT * FROM Employees
WHERE Name BETWEEN 'ANNI' AND 'POOJA';
✅ Result:-
| ID | Name | Department | Salary | JoinDate |
|---|---|---|---|---|
| 1 | ANNI | IT | 10000 | 2023-03-15 |
| 4 | MEENA | HR | 8000 | 2024-01-10 |
| 2 | POOJA | IT | 90000 | 2024-07-01 |
✅ Example 4 – BETWEEN with Dates
Find all employees who joined between January 1, 2023 and December 31, 2023.
✅ SELECT Query:-
SELECT * FROM Employees
WHERE JoinDate BETWEEN '2023-01-01' AND '2023-12-31';
✅ Result:-
| ID | Name | Department | Salary | JoinDate |
|---|---|---|---|---|
| 1 | ANNI | IT | 10000 | 2023-03-15 |
| 5 | MEENA | Sales | 12000 | 2023-06-30 |
'YYYY-MM-DD' with BETWEEN for consistency across all databases. RAJ joined in 2022 and POOJA/SUJAN joined in 2024 — all outside the 2023 range.
✅ Example 5 – BETWEEN Combined with IN Operator
Find IT or Sales employees whose salary is between 5000 and 15000.
✅ SELECT Query:-
SELECT * FROM Employees
WHERE Salary BETWEEN 5000 AND 15000
AND Department IN ('IT', 'Sales');
✅ Result:-
| ID | Name | Department | Salary | JoinDate |
|---|---|---|---|---|
| 1 | ANNI | IT | 10000 | 2023-03-15 |
| 5 | MEENA | Sales | 12000 | 2023-06-30 |
✅ BETWEEN vs >= AND <= Comparison
Both give identical results. Choose based on readability preference.
| Feature | BETWEEN | >= AND <= |
|---|---|---|
| Result | Identical | Identical |
| Boundary values | Inclusive (both ends) | Inclusive (both ends) |
| Readability | Cleaner and shorter | More verbose |
| Works with numbers | ✅ Yes | ✅ Yes |
| Works with dates | ✅ Yes | ✅ Yes |
| Works with text | ✅ Yes | ✅ Yes |
| NOT version | NOT BETWEEN | < value1 OR > value2 |
>= AND <= when you need to mix different columns or more complex conditions in the same WHERE clause.
✅ Key Points to Remember
✅ BETWEEN is inclusive — both boundary values are included in the result.
✅ Works with numbers, text, and dates — one operator for all three data types.
✅ NOT BETWEEN excludes the range — rows equal to the boundaries are also excluded.
✅ BETWEEN = >= AND <= — same result, BETWEEN is just cleaner to write.
✅ Always use single quotes for text and dates — BETWEEN 'ANNI' AND 'POOJA' and BETWEEN '2023-01-01' AND '2023-12-31'.
✅ Use standard date format — always write dates as 'YYYY-MM-DD' for compatibility across databases.
✅ Text BETWEEN depends on collation — results may vary by database. Always test in your environment.
✅ Common SQL BETWEEN Mistakes to Avoid
Wrong:
WHERE Salary BETWEEN 10000 AND 5000 — most databases return 0 rows when the lower bound is greater than the upper bound.Correct:
WHERE Salary BETWEEN 5000 AND 10000 — always put the smaller value first.
If you need to exclude boundary values, use
> and < instead: WHERE Salary > 5000 AND Salary < 10000 excludes 5000 and 10000. BETWEEN always includes them.
Wrong:
BETWEEN '15-03-2023' AND '30-06-2023' — may fail or give wrong results in many databases.Correct:
BETWEEN '2023-03-15' AND '2023-06-30' — always use YYYY-MM-DD format.
Wrong:
WHERE Name BETWEEN ANNI AND POOJACorrect:
WHERE Name BETWEEN 'ANNI' AND 'POOJA' — text and date values always need single quotes.
✅ Frequently Asked Questions (FAQ)
column >= value1 AND column <= value2.BETWEEN 5000 AND 10000 includes rows with salary = 5000 and salary = 10000.WHERE JoinDate BETWEEN '2023-01-01' AND '2023-12-31' returns all rows where JoinDate falls within the year 2023 — both boundary dates included. Always use YYYY-MM-DD format.WHERE Salary NOT BETWEEN 5000 AND 10000 returns employees whose salary is less than 5000 or greater than 10000. Boundary values (5000 and 10000) are excluded.BETWEEN value1 AND value2 is simply a cleaner, more readable shorthand for column >= value1 AND column <= value2. Both include the boundary values.WHERE Name BETWEEN 'ANNI' AND 'POOJA' returns names that fall alphabetically between ANNI and POOJA inclusive. Results depend on the database collation settings.