11. Subqueries

“We can’t solve problems by using the same kindof thinking we used when we created them.”

—Albert Einstein

Topics Covered in This Chapter

What Is a Subquery?

Subqueries as Column Expressions

Subqueries as Filters

Uses for Subqueries

Sample Statements

Summary

Problems for You to Solve

In the previous three chapters, we showed you many ways to work with data from more than one table. All the techniques we’ve covered to this point have been focused on linking subsets of information—one or more columns and one or more rows from an entire table or a query embedded in the FROM clause. We’ve also explored combining sets of information using the UNION operator. In this chapter, we’ll show you effective ways to fetch a single column from ...

Get SQL Queries for Mere Mortals®: A Hands-On Guide to Data Manipulation in SQL, Third Edition 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.