Subquery
Meaning in databases & SQL, with examples
In databases & SQL, subquery means: A query written inside another query, in brackets, whose result is used by the outer query, for example as a list of values to filter by.
In Turkish: alt sorgu, iç içe sorgu
How it is used
Also called an inner or nested query. Subqueries appear in WHERE (… IN (SELECT …)), in FROM as a derived table, or in the SELECT list. A correlated subquery refers to the outer query and runs once per row, which can be slow; a join or CTE is often clearer.
Example sentences
The subquery returns the IDs of customers who ordered last month.
Rewriting the correlated subquery as a join cut the run time in half.
Common collocations
- correlated subquery
- nested subquery
- subquery in the WHERE clause
- rewrite a subquery
Related terms
This word in other fields
The same English word can have a different meaning in another field:
More terms: SQL Statements and Queries
Practise with graded reading
Reading at the right level is the fastest way to make new words stick. Pick free English books by level:
