A subquery, sometimes called a sub-SELECT, is a query whose results are used by another query. The main query uses the result set of the subquery as a comparison value for a selection criterion.

 

Suppose, for example, that you want a list of employees who are not members of any professional organizations. For each employee in the PERSONAL_DATA table, you must determine whether his or her employee ID is in the MEMBERSHIP table. That is, you must compare the value in the PERSONAL_DATA.EMPLID field to the results of a subquery that selects the EMPLID values from the MEMBERSHIP table.

 

In this topic, you will review subqueries.


Table of Contents