Oracle/union and intersect
What is the difference between union and intersect in plsql?
In SQL (in this case ORACLE SQL) the UNION operator is used to combine the result sets of 2 or more Oracle SELECT statements. It removes duplicate rows between the various SELECT statements.
The UNION ALL operator does the same except it does not remove duplicate rows between the various SELECT statements.
The INTERSECT operator is used to is used to return the results of 2 or more SELECT statements. However, it only returns the rows selected by all queries or data sets. If a record exists in one query and not in the other, it will be omitted from the INTERSECT results.
You would typically use the INTERSECT operator to find what's common between the result set of 2 or more ORACLE SELECT statements. The UNION operator is used to combine the results of 2 or more ORACLE SELECT statements (excluding duplicates).
Illustrated example: http://www.programering.com/a/MTO4gzMwATE.html
UNION operator: http://www.techonthenet.com/oracle/union.php
UNION ALL operator: http://www.techonthenet.com/oracle/union_all.php
INTERSECT operator: http://www.techonthenet.com/oracle/intersect.php
I hope this helps.