Using Joins

A query that extracts data from more than one table must perform a join. In the following sections, I’ll explain the different types of joins (Table 7.1), why they’re used, and how to create SELECT statements that use them.

The important characteristics of joins are:

  • The two join operands (input tables) usually are called the first table and the second table, but they are called the left table and the right table in outer joins, in which table order matters.

  • The tables always are joined row by row and side by side by satisfying whatever join condition(s) you specify in the query.

  • Rows that don’t match may be included or excluded, depending on the type of join.

  • Values in joined columns usually are compared for equality (=), but you also ...

Get SQL: Visual QuickStart Guide 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.