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.
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.

