June 2008
Beginner
496 pages
10h 41m
English
Recall from Chapter 2 that set theory is fundamental to the relational model. But whereas mathematical sets are unchanging, database sets are dynamic—they grow, shrink, and otherwise change over time. This chapter covers the following SQL set operators, which combine the results of two SELECT statements into one result:
UNION returns all the rows returned by both queries, with duplicates removed.
INTERSECT returns all rows common to both queries (that is, all distinct rows retrieved by both queries).
EXCEPT returns all rows from the first query without the rows that appear in the second query, with duplicates removed.
These set operations aren’t joins, but you can mix and chain them to combine two or more tables.
Read now
Unlock full access