Subqueries can be nested in `WHERE`, `SELECT`, and `FROM` statements. For better readability, consider refactoring any subqueries to a [[common table expression]].
## correlated subquery
A **correlated** or **synchronized** subquery has a reference in the inner query to a value from the outer query. These queries can be very slow.
A correlated subquery works like a nested loop: the subquery only has access to rows related to a single record at a time in the outer query. The technique relies on table aliases to identify two different uses of the same table, one in the outer query and the other in the subquery.
One way to interpret the line in the WHERE clause that references the two table is “… where the correlated values are the same”.
For example (from SQLZoo.net)
```SQL
SELECT continent, name, area FROM world x
WHERE area >= ALL
(SELECT area FROM world y
WHERE y.continent=x.continent
AND population>0)
```