Exists
Transact-SQL subqueries using EXISTS statement transformation details
Some parts in the output code are omitted for clarity reasons.
Types of Subqueries
Subqueries can be categorized as correlated or uncorrelated:
A correlated subquery, refers to one or more columns from outside of the subquery. (The columns are typically referenced inside the WHERE clause of the subquery.) A correlated subquery can be thought of as a filter on the table that it refers to, as if the subquery were evaluated on each row of the table in the outer query.
An uncorrelated subquery, has no such external column references. It is an independent query, the results of which are returned to and used by the outer query once (not per row).
The EXISTS statement is considered a correlated subquery.
Source Code
Expected Code
Last updated