Explanation Of SET Operators




1). UNION:-
This operator combines the result of First query and result of second query and display common records from both query.                           
Multiple queries can be put together and their output can be combined using the union clause. The union clause merges the output of two or more queries into a single set of row and column.
Syntax:-  <Query1> UNION <Query2>
Example:-
Table:- subject
Exam1
Exam2
C.F
V.B
CONM
C.F
ACCESS
ORACLE
ORACLE
ACCESS

Select exam1 from subject UNION select exam2 from subject;
It display only unique data.
2). UNION ALL:-
Same as union except that it will not eliminate duplicate values.
Syntax:-  <Query1> UNION  ALL<Query2>
Example:-
Select exam1 from subject UNION ALL select exam2 from subject;
It will display duplicate data also.

3). MINUS:-
Multiple queries can be put together and their output combined using the minus clause. The minus clause outputs the row produced by the first query, after filtering the rows retrieved by the second query.
Syntax:-  <Query1> MINUS<Query2>
Example:-
Select exam1 from subject MINUS select exam2 from subject;
Exam1:-        Exam2:-×
4). INTERSECT:-
Multiple queries can be put together and their output combined using the intersect clause. The intersect clause outputs only rows produced by both the queries intersected i.e. the output is an intersect clause will include only those rows that are retrieved common to both the queries.
Syntax:-  <Query1> INTERSECT<Query2>
Example:-
Select exam1 from subject intersect select exam2 from subject;
Explanation Of SET Operators Explanation Of SET Operators Reviewed by Unknown on 7:26:00 AM Rating: 5

No comments:

Powered by Blogger.