O'Reilly logo

Joe Celko's SQL for Smarties, 5th Edition by Joe Celko

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 16

Set Operations

Abstract

Since SQL is based on sets, it includes classic set operations, with extensions for multisets.

Keywords

ALL

DISTINCT

EXCEPT

EXCEPT ALL

INTERSECT

INTERSECT ALL

Multisets (bags)

Proper subsets

Redundant duplicates

Set equality

UNION

UNION ALL

Union compatible

By set operations, I mean union, intersection, and set differences where the sets in SQL are tables. These are the basic operators used in elementary set theory, which has been taught in the United States public school systems for decades. Since the relational model is based on sets, you would expect that SQL would have had a good variety of set operators. But there is a problem in SQL that you did not have in high school set theory. SQL tables are multisets ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required