Using subqueries
You can use subqueries in a search condition as another way to select data. Subqueries can be used anywhere an expression can be used.
Conceptually, a subquery is evaluated whenever a new row or a group of rows must be processed. In fact, if the subquery is the same for every row or group, it is evaluated only once. Subqueries like this are said to be uncorrelated.
Some subqueries return different values from row to row or group to group. The mechanism that allows this is called correlation, and the subqueries are said to be correlated.
- Subqueries in SELECT statements
Subqueries further refine your search conditions in SELECT statements.
- Correlated subqueries
A correlated subquery is a subquery that SQL might need to re-evaluate when it examines each new row (the WHERE clause) or each group of rows (the HAVING clause) in the outer-level SELECT statement.
Parent topic:
Data manipulation language
Related reference
Expressions in the WHERE clause
Defining complex search conditions