Data Analytics & Visualization All-in-One For Dummies
by Jack A. Hyman, Luca Massaron, Paul McFedries, John Paul Mueller, Lillian Pierson, Jonathan Reichental, Joseph Schmuller, Alan R. Simon, Allen G. Taylor
Chapter 7
Joining Data Together in SQL
IN THIS CHAPTER
Combining data from multiple tables into a single result table
Knowing when to use the ON and WHERE clauses
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 ...