IN

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Tests whether an expression matches any row returned by a subquery. Returns a boolean result.

Syntax 

1<expression> IN ( <subquery> )

Arguments 

Required 

  • <expression>: The left-hand value to evaluate and compare against each row of the subquery result.
  • <subquery>: A parenthesized subquery that returns exactly one column.

Returns 

Returns true if any subquery row equals the left-hand expression. Returns false if no equal row is found, including when the subquery returns no rows.

Returns NULL if the left-hand expression is NULL, or if there are no equal right-hand values and at least one right-hand row is NULL.

Considerations 

  • The subquery must return exactly one column.
  • IN is equivalent to = ANY.
  • To avoid unexpected results from NULL comparisons, filter out NULL values in your subquery (for example, WHERE column IS NOT NULL).

Examples 

Match Against Subquery Results 

Return rows whose value appears in the subquery result.

1SELECT col1
2FROM tab1
3WHERE col1 IN (SELECT col2 FROM tab2);

Related Documentation