Prectical 8
Prectical 8
ALT
PRACTICAL NO: 08
AIM: Implement SQL queries using Set operators like Union, unionall,
Intersect, Minus etc
SQL supports few Set operations which can be performed on the table data. These are
used to get meaningful results from data stored in the table, under different special
conditions.
In this tutorial, we will cover 4 different types of SET operations, along with example:
UNION
UNION ALL
INTERSECT
MINUS
UNION Operation
UNION is used to combine the results of two or more SELECT statements. However it will
eliminate duplicate rows from its resultset. In case of union, number of columns and
datatype must be same in both the tables, on which UNION operation is being applied.
Example of UNION
UNION ALL
This operation is similar to Union. But it also shows the duplicate rows.
INTERSECT
Intersect operation is used to combine two SELECT statements, but it only retuns the
records which are common from both SELECT statements. In case of Intersect the number
of columns and datatype must be same.
Example of Intersect
ID Name
1 Chintan
2 komal
3 Deepak
ID Name
3 deepak
4 Megha
5 Jayveer
6 Jay
MINUS
The Minus operation combines results of two SELECT statements and return only those in
the final result, which belongs to the first set of the result.
Example of Minus
CONCLUSION:
HENCE WE PERFORM SQL QUERIES USING SET OPERATORS LIKE
UNION, UNION ALL, INTERSECT, MINUS ETC.
5 5 7 8 25
Sign : Date: