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

SQL > SQL Advanced > SQL IN

What is SQL IN?

The SQL IN operator enables a comparison to a list of values or to the results of a SUBSELECT.

Why Use SQL IN?

The SQL IN operator is a clean way to check for inclusion in lists without creating a series of OR clauses.

How To Use SQL IN

SQL IN is used as follows.

SQL IN Syntax

SELECT <column_list>
FROM <table_name>
WHERE <column_name IN (value_list)>

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:

108New York10010
404San Diego4006
415San Jose4003

This SQL Statement with IN is executed:

SELECT branch_nbr, branch_name, region_nbr
FROM branch
WHERE region_nbr IN (200, 400)

Here is the result.

108New York100
415San Jose400

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