Union result set
Create temporary data table
Copy codeThe Code is as follows:
Create table T_TempEmployee (FIdCardNumber VARCHAR (20), FName VARCHAR (20), FAge int, primary key (FIdCardNumber ));
Insert into T_TempEmployee (FIdCardNumber, FName, FAge) VALUES ('20140901', 'sarani ', 33 );
Insert into T_TempEmployee (FIdCardNumber, FName, FAge) VALUES ('20140901', 'Tom ', 26 );
Insert into T_TempEmployee (FIdCardNumber, FName, FAge) VALUES ('20170101', 'alaha', 38 );
Insert into T_TempEmployee (FIdCardNumber, FName, FAge) VALUES ('20140901', 'tina ', 26 );
Insert into T_TempEmployee (FIdCardNumber, FName, FAge) VALUES ('20140901', 'konkaya', 29 );
Insert into T_TempEmployee (FIdCardNumber, FName, FAge) VALUES ('000000', 'fotifa ', 46 );
Union
Copy codeThe Code is as follows:
Select FNumber, FAge from T_Employee
Union
Select FIdCardNumber, FAge from T_TempEmployee
The number and type of queries on and off the union must be consistent.
Copy codeThe Code is as follows:
Select FNumber, FAge, FDepartment from T_Employee
Union
Select FIdCardNumber, FAge, 'temporary employee, no departments' from T_TempEmployee
Union removes duplicate data by default. If he is not removed, union all is used.
Copy codeThe Code is as follows:
Select FName from T_Employee
Union all
Select FName from T_TempEmployee