One Pager Cheat Sheet
- This tutorial covers four
SET operators
-UNION
,UNION ALL
,INTERSECT
andMINUS
- which combine the results of two or more component queries to form a single set of results, while adhering to certain rules. - The UNION set operator combines the results of two or more SELECT operations, removing any duplicate rows during the process.
- The UNION ALL operator allows for duplicate values to be included in the resulting set, as seen in the sample
query
andresulting table
provided. - UNION removes duplicate rows from the
resulting table
, while UNION ALL includes them. - The
INTERSECT
set operator is used to combine two or more SELECT statements, returning only the duplicate rows which are present in each SELECT statement. - The
MINUS
set operator returns the rows from the first query that are not present in the second query, removing any duplicate rows and displaying the result in ascending order. - The
MINUS
operator can be used to get the rows ofTable2
that are not present inTable1
by reversing the order of the two queries.