Mark As Completed Discussion

Introduction

The SET operators are a special kind of operators which serve the purpose of combining the results of two or more component queries. Queries that contain set operators are referred to as compound queries. The result of these operations is a single set, no matter how many SELECT statements will be present in the compound query. The four SET operators which are very frequently used and will be covered in this tutorial are UNION, UNION ALL, INTERSECT, and MINUS.

Introduction
There exist several rules that have to be followed when using such SET Operators:

  • The number of columns in each query's result set must be the same.
  • The data types in each query’s result set must be compatible, respectively.
  • The last statement may include an ORDER BY clause in case we'd like to sort the results.
  • The first select statement must identify the column names or aliases.

Throughout this tutorial, we will be working with the tables shown below, named Table1 and Table2, respectively:

Introduction