Loading…
Instead of writing two conditions with AND, you can use BETWEEN to filter a range of values.
SELECT * FROM products
WHERE price >= 10 AND price <= 50;
SELECT * FROM products
WHERE price BETWEEN 10 AND 50;
Both queries do the exact same thing — but BETWEEN is cleaner and easier to read.
| Detail | Explanation |
|---|---|
| Inclusive | <code>BETWEEN 10 AND 50</code> includes both 10 and 50 |
| Works with text | <code>WHERE name BETWEEN 'A' AND 'M'</code> (alphabetical range) |
| Works with dates | <code>WHERE order_date BETWEEN '2025-01-01' AND '2025-12-31'</code> |
| Order matters | The smaller value must come first |
BETWEEN 50 AND 10 returns nothing — always put the smaller value first!
Find all products with a price between 5 and 100 (inclusive).
Downloading SQL engine… (one-time)
This runs entirely in your browser and is cached for next time.