Saturday, 2 April 2016

SQL Set Operators

        TYPES
            Union
            Union all
            Intersect
            Minus


UNION

This will combine the records of multiple tables having the same structure.

Ex:
     SQL> select * from student1 union select * from student2;

UNION ALL

This will combine the records of multiple tables having the same structure but including duplicates.

Ex:
     SQL> select * from student1 union all select * from student2;

INTERSECT

This will give the common records of multiple tables having the same structure.

Ex:
     SQL> select * from student1 intersect select * from student2;

MINUS

This will give the records of a table whose records are not in other tables having the same structure.
Ex:


     SQL> select * from student1 minus select * from student2;

No comments:

Post a Comment