In Chapter 2, The Basics of SQL for Analytics, you learned how to perform operations with a single table. But what if you need data from two or more tables? In this section, you will assemble data in multiple tables using joins and unions.
Connecting Tables Using JOIN
Most of the time, the data you are interested in is spread across multiple tables. A simple
SELECT statement over one table will not be enough to get you what you need. Fortunately, SQL has methods for bringing related tables together using the
To illustrate, look at two tables in the
salespeople table looks like this:
salespeople table, you can observe that there is a column called
dealership_id column is a direct reference to the