DBMS SQL Set Operation
DBMS SQL Set Operation
ADVERTISEMENT
Start now
Everything you need to market your business.
2. UnionAll
3. Intersect
4. Minus
1. Union
The SQL Union operation is used to combine the result of two or more SQL SELECT queries.
In the union operation, all the number of datatype and columns must be same in both the
tables on which UNION operation is being applied.
The union operation eliminates the duplicate rows from its resultset.
Syntax
Example:
https://www.javatpoint.com/dbms-sql-set-operation 1/6
2/21/2020 DBMS SQL Set Operation - javatpoint
ID NAME
1 Jack
2 Harry
3 Jackson
ID NAME
3 Jackson
4 Stephan
5 David
ID NAME
1 Jack
2 Harry
3 Jackson
4 Stephan
5 David
2. Union All
Union All operation is equal to the Union operation. It returns the set without removing duplication
and sorting the data.
Syntax:
https://www.javatpoint.com/dbms-sql-set-operation 2/6
2/21/2020 DBMS SQL Set Operation - javatpoint
ID NAME
1 Jack
2 Harry
3 Jackson
3 Jackson
4 Stephan
5 David
3. Intersect
It is used to combine two SELECT statements. The Intersect operation returns the common
rows from both the SELECT statements.
In the Intersect operation, the number of datatype and columns must be the same.
Syntax
Example:
ID NAME
3 Jackson
4. Minus
It combines the result of two SELECT statements. Minus operator is used to display the
rows which are present in the first query but absent in the second query.
Syntax:
Example
https://www.javatpoint.com/dbms-sql-set-operation 3/6
2/21/2020 DBMS SQL Set Operation - javatpoint
Minus query will be:
ID NAME
1 Jack
2 Harry
← prev next →
ADVERTISEMENT
https://www.javatpoint.com/dbms-sql-set-operation 4/6