O'Reilly logo

The Language of SQL, Second Edition by Larry Rockoff

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

15. Set Logic

Keywords Introduced

UNION  •  UNION ALL  •  INTERSECT  •  EXCEPT

The various joins and subqueries of the previous few chapters have dealt with different ways of combining data from multiple tables. The result, however, has always been a single SELECT statement. Now we’ll extend the concept of combining data in multiple tables to the possibility of combining data from multiple queries. In other words, we’ll look at a way to write a single SQL statement that contains more than one SELECT to retrieve data.

The concept of combining queries is often referred to as set logic, a term taken from mathematics. Each SELECT query can be referred to as a set of data. The set logic we’ll employ and examine in this chapter will address four basic ...

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