Filtering by Subquery

The database tables used in all the lessons in this book are relational tables. (See Appendix A, “Sample Table Scripts,” for a description of each of the tables and their relationships.) Orders are stored in two tables. The Orders table stores a single row for each order containing order number, customer ID, and order date. The individual order items are stored in the related OrderItems table. The Orders table does not store customer information. It only stores a customer ID. The actual customer information is stored in the Customers table.

Now suppose you wanted a list of all the customers who ordered item RGAN01. What would you have to do to retrieve this information? Here are the steps:

1.
Retrieve the order numbers ...

Get Sams Teach Yourself SQL in 10 Minutes, Second 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.