Difference between revisions of "Set Operators"
(Created page with " Set operators are used to combine the results of two (or more) SELECT statements. Valid set operators in Oracle 11g are UNION, UNION ALL, INTERSECT, and MINUS. When used with...") |
|||
Line 8: | Line 8: | ||
removes the second query’s results from the output if they are also found in the first query’s | removes the second query’s results from the output if they are also found in the first query’s | ||
results. INTERSECT and MINUS set operations produce unduplicated results. | results. INTERSECT and MINUS set operations produce unduplicated results. | ||
== UNION== | |||
Returns the results of both queries and removes duplicates | |||
== UNION ALL == | |||
Returns the results of both queries but includes duplicates | |||
==INTERSECT == | |||
Returns only the rows included in the results of both queries | |||
==MINUS == | |||
Subtracts the second query's result if they're also returned in the first query's results | |||
[[#Select Command|Back To Top]]-[[Main_Page| Home]] - [[Oracle_SQL|Category]] | [[#Select Command|Back To Top]]-[[Main_Page| Home]] - [[Oracle_SQL|Category]] |
Revision as of 01:09, 24 October 2017
Set operators are used to combine the results of two (or more) SELECT statements. Valid set operators in Oracle 11g are UNION, UNION ALL, INTERSECT, and MINUS. When used with two SELECT statements, the UNION set operator returns the results of both queries. However, if there are any duplicates, they are removed, and the duplicated record is listed only once. To include duplicates in the results, use the UNION ALL set operator. INTERSECT lists only records that are returned by both queries; the MINUS set operator removes the second query’s results from the output if they are also found in the first query’s results. INTERSECT and MINUS set operations produce unduplicated results.
UNION
Returns the results of both queries and removes duplicates
UNION ALL
Returns the results of both queries but includes duplicates
INTERSECT
Returns only the rows included in the results of both queries
MINUS
Subtracts the second query's result if they're also returned in the first query's results