In Operator
The IN
operator is the shorthand for mulitple OR
conditions in a WHERE
clause.
Syntax
SELECT <columns> FROM <table-name>
WHERE <attribute-name> IN (<value-1>, <value-2>...);
or
SELECT <columns> FROM <table-name>
WHERE <column-name> IN (SELECT <statement>);
Example
SELECT * FROM Companies
WHERE founded IN (1923, 1962);
or
SELECT * FROM Companies
WHERE founded IN
(SELECT founded FROM Companies WHERE founded < 1975);
Name | Type | Founded | HQ |
---|---|---|---|
Walmart | Retail | 1962 | United States |
Disney | Entertainment | 1923 | United States |