BETWEEN a AND b selects values within a range, including both ends. It works with numbers, text and dates.
NOT BETWEEN selects values outside the range.
Select values within a range.
✍️ 3 exercises + code challenge in this lessonBETWEEN a AND b selects values within a range, including both ends. It works with numbers, text and dates.
NOT BETWEEN selects values outside the range.
Mastering SQL BETWEEN helps you write clean and reliable SQL code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
SELECT ProductName, Price FROM Products
WHERE Price BETWEEN 1000 AND 30000
ORDER BY Price;
SELECT OrderID, OrderDate FROM Orders
WHERE OrderDate BETWEEN '2026-03-01' AND '2026-06-30';
Check what you learned in “SQL BETWEEN”.
Select prices from 1000 to 5000.
WHERE Price 1000 AND 5000
Does BETWEEN include the boundary values?
Select ProductName of products with a stock between 20 and 100, sorted by ProductName.
Free sign-in required · Google login available
Stuck on something?
Ask the community in the CodesInTech forum.
Need a developer?
Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.
Explore Our Services