Skip to main content
The IN and NOT IN operators check if an expression is included or not included in the values returned by a subquery.

Synopsis


Description


The left-hand expression or row_constructor are evaluated and compared to each row of the subquery result. The result of IN is “true” if any equal subquery row is found. The result is “false” if no equal row is found. Vice versa, the result of NOT IN is “false” if any equal subquery row is found. The result is “true” if no equal row is found. Those two cases include the case where the subquery returns no rows.

Parameters


expression A column_name or an expression to be compared with the subquery. The subquery (in the right-hand side in the parenthesized) must return exactly one column. row_constructor A composite value that builds a row value. The subquery (in the right-hand side in the parenthesized) must return the exact same number of columns. The constructed row columns order should match the subquery columns data types.

Examples


Return the rows that their column value is included in the subquery:
Return the rows that their expression is not included in the subquery values:
Return the rows based on a row constructor: