I. Joint result set
1. Simple result set Union:
Select Fnumber,fname,fage from T_employee Union select Fidcardnumber,fname,fage from T_employee
2. Basic principle: Each result set must have the same number of columns: the columns of each result set must be type-compatible.
3. Select Fnumber,fname,fdepartment from T_employee Union select Fidcardnumber,fname,fage, ' temp, no department ' from T_employee
Second, Union all
1. Select Fname,fage from T_employee Union Select fname,fage from T_tempemployee.
Union merges two query result sets and merges the rows of data that are completely duplicated into one.
2. Select FName from T_employee UNION ALL Select FName from T_tempemployee.
Union is inefficient because it is being scanned for duplicate values, so if you are not sure that you want to merge duplicate rows, use UNION ALL.
Iii. Case 1
Iv. Case Two
SQL from getting started to basic –08 Union, union all, and cases