SQL BETWEEN


David Haertzen David Haertzen, Tutorial Author
Check out our
Data Warehousing Tutorial.
Previous | Next

SQL > SQL Advanced > SQL BETWEEN


What is SQL BETWEEN?

The SQL BETWEEN operator enables a comparison to a range of values.

Why Use SQL BETWEEN?

The SQL IN operator is a clean way to check for inclusion in a range without requiring an AND operator.


How To Use SQL BETWEEN

SQL BETWEEN is used as follows.

SQL BETWEEN Syntax

 
SELECT <column_list>
FROM <table_name>
WHERE <column_name> BETWEEN
<lower_value> AND <higher_value>
 

SQL BETWEEN Example

The following example lists rows in the branch that have employee_count in range from 4 to 7.

Here are the contents of the table:

Table: BRANCH
branch_nbrbranch_nameregion_nbremployee_count
108New York10010
110Boston1006
212Chicago2005
404San Diego4006
415San Jose4003

This SQL Statement with BETWEEN is executed:

 
SELECT branch_nbr, branch_name, employee_count
FROM branch
WHERE employee_count BETWEEN
4 AND 7
 

Here is the result.

branch_nbrbranch_nameemployee_count
110Boston6
212Chicago5
404San Diego6

Copyright© 1999-2015, First Place Software, Inc.