7/15/25, 10:33 AM SQL BETWEEN Operator
Tutorials Exercises Services Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
SQL BETWEEN Operator
❮ Previous Next ❯
The SQL BETWEEN Operator
The BETWEEN operator selects values within a given range. The values can be numbers,
text, or dates.
The BETWEEN operator is inclusive: begin and end values are included.
Example Get your own SQL Server
Selects all products with a price between 10 and 20:
SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20;
Try it Yourself »
Syntax
SELECT column_name(s)
FROM table_name
[Link] 1/10
7/15/25, 10:33 AM SQL BETWEEN Operator
WHERE column_name BETWEEN value1 AND value2;
Tutorials Exercises Services Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
Demo Database
Below is a selection from the Products table used in the examples:
ProductID ProductName SupplierID CategoryID Unit Price
1 Chais 1 1 10 boxes x 18
20 bags
2 Chang 1 1 24 - 12 oz 19
bottles
3 Aniseed Syrup 1 2 12 - 550 ml 10
bottles
4 Chef Anton's Cajun 2 2 48 - 6 oz 22
Seasoning jars
5 Chef Anton's Gumbo 2 2 36 boxes 21.35
Mix
ADVERTISEMENT
NOT BETWEEN
To display the products outside the range of the previous example, use NOT BETWEEN :
Example
[Link] 2/10
7/15/25, 10:33 AM SQL BETWEEN Operator
SELECT * FROM Products
Tutorials Exercises Services
WHERE Price NOT BETWEEN 10 AND 20;
Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
Try it Yourself »
BETWEEN with IN
The following SQL statement selects all products with a price between 10 and 20. In
addition, the CategoryID must be either 1,2, or 3:
Example
SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20
AND CategoryID IN (1,2,3);
Try it Yourself »
BETWEEN Text Values
The following SQL statement selects all products with a ProductName alphabetically
between Carnarvon Tigers and Mozzarella di Giovanni:
Example
SELECT * FROM Products
WHERE ProductName BETWEEN 'Carnarvon Tigers' AND 'Mozzarella di Giovanni'
ORDER BY ProductName;
Try it Yourself »
[Link] 3/10
7/15/25, 10:33 AM SQL BETWEEN Operator
The following SQL statement selects all products with a ProductName between
Tutorials
Carnarvon Tigers andExercises
Chef Anton's Services
Cajun Seasoning: Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
Example
SELECT * FROM Products
WHERE ProductName BETWEEN "Carnarvon Tigers" AND "Chef Anton's Cajun
Seasoning"
ORDER BY ProductName;
Try it Yourself »
NOT BETWEEN Text Values
The following SQL statement selects all products with a ProductName not between
Carnarvon Tigers and Mozzarella di Giovanni:
Example
SELECT * FROM Products
WHERE ProductName NOT BETWEEN 'Carnarvon Tigers' AND 'Mozzarella di Giovanni'
ORDER BY ProductName;
Try it Yourself »
BETWEEN Dates
The following SQL statement selects all orders with an OrderDate between '01-July-1996'
and '31-July-1996':
Example
[Link] 4/10
7/15/25, 10:33 AM SQL BETWEEN Operator
SELECT * FROM Orders
Tutorials Exercises Services
WHERE OrderDate BETWEEN #07/01/1996# AND #07/31/1996#;
Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
Try it Yourself »
OR:
Example
SELECT * FROM Orders
WHERE OrderDate BETWEEN '1996-07-01' AND '1996-07-31';
Try it Yourself »
Sample Table
Below is a selection from the Orders table used in the examples:
OrderID CustomerID EmployeeID OrderDate ShipperID
10248 90 5 7/4/1996 3
10249 81 6 7/5/1996 1
10250 34 4 7/8/1996 2
10251 84 3 7/9/1996 1
10252 76 4 7/10/1996 2
?
Exercise
[Link] 5/10
7/15/25, 10:33 AM SQL BETWEEN Operator
Which SQL statement selects all products with a price between 10 and 20?
Tutorials Exercises Services Sign In
HTML
SELECTJAVASCRIPT
CSS * FROM ProductsSQL
WHERE Price
PYTHON= 10 ANDJAVA
Price = 20;
PHP HOW TO [Link] C
SELECT * FROM Products WHERE Price BETWEEN 10 AND 20;
SELECT * FROM Products WHERE Price >= 10 OR Price <= 20;
SELECT * FROM Products WHERE Price LIKE '10-20';
Submit Answer »
❮ Previous Next ❯
Track your progress - it's free! Sign Up Log in
ADVERTISEMENT
[Link] 6/10
7/15/25, 10:33 AM SQL BETWEEN Operator
Tutorials Exercises Services Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
[Link] 7/10
7/15/25, 10:33 AM SQL BETWEEN Operator
COLOR PICKER
Tutorials Exercises Services Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
ADVERTISEMENT
ADVERTISEMENT
[Link] 8/10
7/15/25, 10:33 AM SQL BETWEEN Operator
Tutorials Exercises Services Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
ADVERTISEMENT
PLUS SPACES
GET CERTIFIED FOR TEACHERS
FOR BUSINESS CONTACT US
Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
[Link] Tutorial
Bootstrap Tutorial
PHP Tutorial
Java Tutorial
[Link] 9/10
7/15/25, 10:33 AM SQL BETWEEN Operator
C++ Tutorial
Tutorials jQuery Tutorial
Exercises
Top References
Services Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
[Link] Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
Angular Reference
jQuery Reference
Top Examples Get Certified
HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
[Link] Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate
XML Examples C# Certificate
jQuery Examples XML Certificate
FORUM ABOUT ACADEMY
W3Schools is optimized for learning and training. Examples might be simplified to improve
reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot
warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of use,
cookie and privacy policy.
Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by [Link].
[Link] 10/10