Skip to Content
Learn SQL in a Month of Lunches
book

Learn SQL in a Month of Lunches

by Jeff Iannucci
February 2025
Beginner content levelBeginner
304 pages
8h 8m
English
Manning Publications
Content preview from Learn SQL in a Month of Lunches

10 Combining queries with set operators

In the past few chapters, we examined ways to join tables based on the way they relate to one another. Every query we’ve written has had a single SELECT statement. But this chapter will show how to write a query with multiple SELECT statements and combine the results into a single set of data.

This technique can be useful when we need to evaluate results that require different conditions, such as querying values in different tables with no key to join them. Although we’ve seen that null values are excluded from results when we use joins, we’ll see how to use SQL to include null values if those values exist in two data sets and we want to include them in our results.

10.1 Using set operators

We’ve written ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, 4th Edition

SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, 4th Edition

John L. Viescas
SQL Cookbook, 2nd Edition

SQL Cookbook, 2nd Edition

Anthony Molinaro, Robert de Graaf

Publisher Resources

ISBN: 9781633438576Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentPurchase Link