Day 7. Embedding Subqueries into Queries

A subquery is a query whose results are passed as the argument for another query. Subqueries enable you to bind several queries together. By the end of the day, you will understand and be able to do the following:

  • Build a subquery

  • Use the keywords EXISTS, ANY, and ALL with your subqueries

  • Build and use correlated subqueries

Today we will be working with the PART and ORDERS tables. To ensure that you have these tables created and that data has been inserted into them, please do the following in your MySQL database. The database bob in the example below should be substituted with the name of the database you created and have been putting into your tables:

 mysql> use bob; Database changed mysql> show tables; ...

Get Sams Teach Yourself SQL in 21 Days, Fourth 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.