Qualifying Column Names in Subqueries

Recall from “Qualifying Column Names” in Chapter 7 that you can qualify a column name explicitly with a table name to identify the column unambiguously. In statements that contain subqueries, column names are qualified implicitly by the table referenced in the FROM clause at the same nesting level.

In Listing 8.15a, for example, the column names are qualified implicitly, meaning:

  • The column pub_id in the outer query’s WHERE clause is qualified implicitly by the table publishers in the outer query’s FROM clause.

  • The column pub_id in the subquery’s SELECT clause is qualified implicitly by the table titles in the subquery’s FROM clause.

Listing 8.15b shows Listing 8.15a with explicit qualifiers. See Figure 8.15 ...

Get SQL: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.