SQL BETWEEN Operator
BETWEEN keeps values within a range. It includes both ends, so BETWEEN 4 AND 5 means >= 4 AND <= 5.
Updated December 1, 2026
Syntax
WHERE column BETWEEN low AND high
A range of numbers
Drinks from $4 to $5, inclusive. Mocha at exactly $5.00 is included.
SELECT name, price
FROM drinks
WHERE price BETWEEN 4 AND 5;
| name | price |
|---|---|
| Latte | 4.5 |
| Cappuccino | 4.25 |
| Mocha | 5 |
| Cold Brew | 4.75 |
| Chai Latte | 4.75 |
| Hot Chocolate | 4 |
A range of dates
Orders from July 2 to July 4, 2024.
SELECT id, ordered_on
FROM orders
WHERE ordered_on BETWEEN '2024-07-02' AND '2024-07-04';
| id | ordered_on |
|---|---|
| 3 | 2024-07-02 |
| 4 | 2024-07-02 |
| 5 | 2024-07-03 |
| 6 | 2024-07-03 |
| 7 | 2024-07-04 |
NOT BETWEEN
Everything outside the range.
SELECT name, calories
FROM drinks
WHERE calories NOT BETWEEN 100 AND 250;
| name | calories |
|---|---|
| Espresso | 5 |
| Mocha | 290 |
| Cold Brew | 5 |
| Peppermint Tea | 0 |
| Hot Chocolate | 320 |
Common mistakes
- Putting the larger value first.
BETWEEN 5 AND 4matches nothing. - Date-times:
BETWEEN '2024-07-01' AND '2024-07-04'misses times later on July 4. Use>= '2024-07-01' AND < '2024-07-05'for timestamps. - Forgetting that both ends are included when ranges must not overlap.
Practice BETWEEN Operator interactively
Write real queries in your browser and get instant feedback in the lesson “IN, BETWEEN, LIKE” (Unit 2). New learners can start free from the first lesson.
Frequently asked questions
Is SQL BETWEEN inclusive?
Yes, in every major database it includes both the low and the high value.
Does BETWEEN work with text?
Yes, it compares alphabetically, but results can surprise you: BETWEEN 'A' AND 'C' excludes “Cappuccino”, because it sorts after “C”.