What does subquery mean?

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.

ˈsʌbˌkwɪrinounCommon term

Databases & SQL vocabulary · SQL Statements and Queries

In Turkish: alt sorgu, iç içe sorgu

Also used in: Software Engineering

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

  1. The subquery returns the IDs of customers who ordered last month.

  2. 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

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: