3.2. Restrictions on Subqueries in WHERE Clauses

The following restrictions to the use of subqueries in WHERE SQL clauses require an understanding of the concepts discussed in the preceeding section, Understanding Subqueries.

  • Subqueries must appear on the right hand side of an expression.

  • Nested subqueries are not supported.

  • Only one subquery expression is allowed for a single query.

  • Subquery predicates must appear as top level conjuncts.

  • Subqueries support four logical operators in query predicates: IN , NOT IN, EXISTS, and NOT EXISTS.

  • The left hand side of a subquery must qualify all references to table columns.

  • References to columns in the parent query are allowed only in the WHERE clause of the subquery.

  • Subquery predicates that reference a column in a parent query must use the Equals To (=) predicate operator.

  • Subquery predicates may not refer only to columns in the parent query.

  • Correlated subqueries with an implied GROUP BY statement may return only one row.

  • All unqualified references to columns in a subquery must resolve to tables in the subquery.

  • Correlated subqueries cannot contain windowing clauses.

[Note]Note

The IN and NOT IN logical operators may select only one column in a WHERE clause subquery.

[Note]Note

The EXISTS and NOT EXISTS operators must have at least one correlated predicate.


loading table of contents...