SQL

Subquery

English

Overview

A SQL statement embedded inside another SQL statement.

Details

A SELECT statement nested inside another SELECT, used within clauses such as WHERE or FROM as a condition or a temporary result set. A correlated subquery, which re-runs once per row of the outer query, can become extremely slow against a large table -- in practice, rewriting it as a JOIN often speeds things up significantly.

More Database terms