Going Beyond Joins: UNION, INTERSECT, MINUS

The relational model calls for three more operations: UNION, INTERSECT, and MINUS (see Figure 7.4). These correspond to the set operations union, intersection, and difference.

  • UNION returns results from sets of queries. By default, it removes duplicate rows so you see all unique rows and one copy (not two) of duplicates.

  • INTERSECT returns common results from sets of queries—that is, only the duplicates.

  • MINUS returns results from sets of queries. It shows the rows from one query or another, without the values that appear in the other query.

Figure 7.4. UNION, INTERSECT, MINUS

UNION is widely supported; ...

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition 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.