Chapter 7

Joining Data Together in SQL

IN THIS CHAPTER

Bullet Combining data from multiple tables into a single result table

Bullet Knowing when to use the ON and WHERE clauses

Bullet Working with a clustering index

The preceding chapter describes how to use subqueries and relational operators to pull data from multiple tables in relational databases. This chapter shows how to collect information from multiple tables by using JOIN operators. A number of different joins exist, and each performs a somewhat different operation. Depending on what you want in terms of information retrieved from multiple tables, one or another of the joins or the other relational operators is likely to give it to you.

JOINS

The UNION, INTERSECT, and EXCEPT operators are valuable in multitable databases in which the tables are union-compatible. In many cases, however, you want to draw data from multiple tables that have very little in common. JOINs are powerful relational operators that combine data from multiple tables into a single result table. The source tables may have little (or even nothing) in common with each other.

SQL supports a number of types of JOINs. The best one to choose in a given situation depends on ...

Get Data Analytics & Visualization All-in-One For Dummies 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.