Joining Multiple Tables in a Single SELECT Statement

Like Dorothy in The Wizard of OZ (who had the power to return home all along), you have had the power to join tables since Day 2, “Introducing the Query,” when you learned about SELECT and FROM. Unlike Dorothy, you don't have to click your heels together three times to perform a join. The two following subsections cover some fundamental material with which you need to begin in order to understand join operations. First, we show you the simplest form of the join, and then how to select a common key between tables through which to perform the join operation. We will use the following two tables, named, cleverly enough, TABLE1 and TABLE2.

Note

The queries in today's examples were produced using ...

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.