A subquery is a SELECT query that is nested within another SELECT, INSERT, UPDATE, or DELETE statement.
A subquery can also be nested inside another subquery.
Subqueries can often be re-written into regular JOINs.
Sometimes an existence subquery can perform better than equivalent non-subquery methods.
A correlated subquery is a subquery whose results depend on the values of the outer query.
SELECT <SELECT list>
FROM <SomeTable>
WHERE <SomeColumn> = (
SELECT <single column>
FROM <SomeTable>
WHERE <condition that results in only one row returned>)
Or:
SELECT <SELECT list>
FROM <SomeTable>
WHERE <SomeColumn> IN (
SELECT <single column>
FROM <SomeTable>
[WHERE <condition>])
|