In list
Returns true when the left operand matches any element in the right-hand list or array.
Category: comparison
SQL symbol: IN
Syntax
sql
<value> IN (<item> [, ...])
<value> IN <array>Parameters
<value>— The value to look for. Acceptsboolean,date,decimal,float,integer,nvarchar,timestamp,varbinary,varchar.<list>— The values to look in - a parenthesised list, or an array-valued expression. Every element must share one type; a mixed list, NULL included, is rejected at plan time rather than being silently skipped. Acceptsarray.
Returns
Examples
sql
SELECT name FROM $planets WHERE name IN ('Earth', 'Mars');Earth
Mars
sql
SELECT 2 IN (1, 2, 3), 9 IN (1, 2, 3);true | false
Signatures
boolean IN array→ booleandate IN array→ booleandecimal IN array→ booleanfloat IN array→ booleaninteger IN array→ booleannvarchar IN array→ booleantimestamp IN array→ booleanvarbinary IN array→ booleanvarchar IN array→ boolean
Notes
IN is a shorthand for a chain of =, and inherits its rules: the comparison is exact and case-sensitive. A list mixing types - IN (NULL, 2) among them - is an error, not a match against the elements that do share a type.