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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.