Pages

Showing posts with label UNION. Show all posts
Showing posts with label UNION. Show all posts

9 August 2013

SQL- UNION and UNION ALL

Q What is the difference between UNION and UNION ALL ?
     UNION: It combines the results of two or more SELECT queries and it will        return only distinct records. It also displays result set in sorted order.

     Consider EmpInfo as first table.


EmpInfo Table

      Consider EmpDetails as second table.

EmpDetails


      UNION is applied on the above two tables.We see that only distinct               records are displayed out of two tables.