IN
membership in a list or subquery (NOT IN with a NULL in the list yields UNKNOWN for every row)
What changes
- Input
- outer row value and a subquery result
- Output or change
- TRUE, FALSE or UNKNOWN per outer row
Syntax at a glance
test_expression [ NOT ] IN ( subquery | expression [ ,...n ] )
Work example
A report needs IN to define which rows satisfy a compound search condition.
Test a match, a nonmatch, and NULL. Write the expected TRUE, FALSE, or UNKNOWN result before running the filter.
Check your work IN. The rows kept by IN are exactly those whose complete condition evaluates to TRUE.
Practice SQL
Open in SQL FlowSELECT Value FROM (VALUES (1), (2), (3)) AS Items(Value) WHERE Value IN (1, 3);
Open Microsoft Learn for full syntax, permissions, and details for your version.