The SQL BETWEEN operator enables a comparison to a range of values.
The SQL IN operator is a clean way to check for inclusion in a range without requiring an AND operator.
SQL BETWEEN is used as follows.
SQL BETWEEN Syntax
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_nbr | branch_name | region_nbr | employee_count |
108 | New York | 100 | 10 |
110 | Boston | 100 | 6 |
212 | Chicago | 200 | 5 |
404 | San Diego | 400 | 6 |
415 | San Jose | 400 | 3 |
This SQL Statement with BETWEEN is executed:
Here is the result.
branch_nbr | branch_name | employee_count |
110 | Boston | 6 |
212 | Chicago | 5 |
404 | San Diego | 6 |
Advertisements:
Infogoal.com is organized to help you gain mastery.
Examples may be simplified to facilitate learning.
Content is reviewed for errors but is not warranted to be 100% correct.
In order to use this site, you must read and agree to the
terms of use, privacy policy and cookie policy.
Copyright 2006-2020 by Infogoal, LLC. All Rights Reserved.