14
Working with Subqueries
In this chapter, you’ll learn what subqueries are and how to use them.
Understanding Subqueries
SELECT
statements are SQL queries. All the SELECT
statements you have seen thus far are simple queries: single statements that retrieve data from individual database tables.
New Term
Query Any SQL statement. However, the term is usually used to refer to SELECT
statements.
SQL also enables you to create subqueries: queries that are embedded in other queries. Why would you want to do this? The best way to understand this concept is to look at a couple of examples.
Filtering by Subquery
The database tables used in all the chapters in this book are relational tables. (See Appendix B, “The Example Tables,” for a description ...
Get MySQL Crash Course, 2nd 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.