In this section, I’ll define some terms and introduce subqueries by giving an example of a SELECT statement that contains a simple subquery. In subsequent sections, I’ll explain the types of subqueries and their syntax and semantics.
Suppose that you want to list the names of the publishers of biographies. The naive approach is to write two queries: one query to retrieve the IDs of all the biography publishers (Listing 8.1 and Figure 8.1), and a second query that uses the first query’s result to list the publisher names (Listing 8.2 and Figure 8.2).
Another alternative is to use a subquery (