SQLite BETWEEN Operator
The BETWEEN Operator
BETWEEN selects values in a range. The begin and end values are included.
This example selects the products with a price from 10 to 20:
NOT BETWEEN
Example
Select the products with a price outside the range 10 to 20:
SELECT * FROM Products
WHERE Price NOT BETWEEN 10 AND 20;
Try it Yourself »
BETWEEN With IN
Example
Select the products with a price from 10 to 20, in category 1, 2 or 3:
SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20
AND CategoryID IN (1, 2, 3);
Try it Yourself »
BETWEEN Text Values
With text, BETWEEN uses alphabetical order:
Example
SELECT * FROM Products
WHERE ProductName BETWEEN 'Carnarvon Tigers'
AND 'Mozzarella di Giovanni'
ORDER BY ProductName;
Try it Yourself »
BETWEEN Dates
In the Northwind database, dates are stored as text in the format YYYY-MM-DD. In this format, text order is the same as date order, so BETWEEN works for dates:
Example
SELECT * FROM Orders
WHERE OrderDate BETWEEN '1996-07-01'
AND '1996-07-31';
Try it Yourself »
Tip: Read more about dates in the SQLite Dates chapter.