The SQL IN operator enables a comparison to a list of values or to the results of a SUBSELECT.
The SQL IN operator is a clean way to check for inclusion in lists without creating a series of OR clauses.
SQL IN is used as follows.
SQL IN Syntax
There must be one or more members of the value_list. Numeric and non-numeric values are supported.
SQL IN Example
The following example selects information from the BRANCH where the region_nbr is IN a specified list of region_nbr values.
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 IN is executed:
Here is the result.
branch_nbr | branch_name | region_nbr |
108 | New York | 100 |
415 | San Jose | 400 |
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.