SQL Between Operator

Thursday, November 17, 2011

tags SQL

The BETWEEN operator is used in a WHERE clause to select a range of data between two values. The values can be numbers, text, or dates.

Syntax


SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value1 AND value2

Examples

Search for records with a customer ID between 50 and 100.


SELECT * FROM Customers
WHERE custID BETWEEN 50 AND 100


Search for records with a customer ID not between 50 and 100.


SELECT * FROM Customers
WHERE custID NOT BETWEEN 50 AND 100

Did you find the page informational and useful? Share it using one of your favorite social sites.

Recommended Books & Training Resources

SQL Cookbook Head First SQL: Your Brain on SQL A Learners Guide