In the previous tutorial we learnt about Union and Union All set operators, the differences between them and their usage. Now in this tutorial we will learn the remaining Set operators in oracle database which includes Intersect and Minus.
Intersect Set Operator
The INTERSECT operator returns rows that are common to both queries. Let’s see an example. For this example I will be using the same tables from the previous tutorial that are Cricket and Football.
SELECT first_name, last_name FROM cricket
 INTERSECT
 SELECT first_name, last_name FROM football;
On execution the resulting set will consist of only those rows that are common to both these tables.
Minus Set Operator
The MINUS operator returns rows in the first query that are not present in the second query. The definition is self-explanatory. Therefore if we execute MINUS set operator on cricket and football tables then all the rows from cricket table which are not present in the second table i.e. football table will get returned and vice versa.
SELECT first_name, last_name FROM cricket
 MINUS
 SELECT first_name, last_name FROM football;
On execution the result set of this query will contain two rows from the cricket table which were not present in the football table.
That’s all about Intersect and Minus set operators. Hope this was helpful. Kindly please share this on your social network and help me reach out to more people. Thanks and have a good day!