Set Operators Archives

Use Set Operators to combine rows from several tables into a single results.

Throughout this blog we have written articles to show you how to combine rows from tables using operators such as UNION, INTERSECTION, and EXCLUDE.

If you are not familiar with how to use set operators, I would start with the article Learn to use Union, Intersect, and Except Clauses.

One of our most popular article looks at the difference between a Join and UNION.  This is something people often confuse, so it is worth a read!

All the examples for this lesson are based on Microsoft SQL Server Management Studio and the sample databases AdventureWorks and WideWorldImporters.  You can get started using these free tools using my guide Getting Started Using SQL Server


Is it possible to use Joins, Subqueries, and Unions in one Query?

A reader recently asked me to help them solve a problem combining data from multiple tables into a single result.  What was interesting was that the solution used the three ways to combine data that we have recently covered, namely:  JOINS, set operators, and subqueries. Given the comprehensive nature of this problem I thought it […]

Continue reading

Learn to use Union, Intersect, and Except Clauses

Intersection, Exception, Union

Learn to use Union, Intersect, and Except Clauses The UNION, INTERSECT, and EXCEPT clauses are used to combine or exclude like rows from two or more tables.  They are useful when you need to combine the results from separate queries into one single result.  They differ from a join in that entire rows are matched […]

Continue reading