SQL進修筆記六 union結合成果集應用。本站提示廣大學習愛好者:(SQL進修筆記六 union結合成果集應用)文章只能為提供參考,不一定能成為您想要的結果。以下是SQL進修筆記六 union結合成果集應用正文
結合成果集
新建暫時工數據表
CREATE TABLE T_TempEmployee (FIdCardNumber VARCHAR(20),FName VARCHAR(20),FAge int,PRIMARY KEY(FIdCardNumber));
INSERT INTO T_TempEmployee(FIdCardNumber,FName,FAge) VALUES('1234567890121','Sarani',33);
INSERT INTO T_TempEmployee(FIdCardNumber,FName,FAge) VALUES('1234567890122','Tom',26);
INSERT INTO T_TempEmployee(FIdCardNumber,FName,FAge) VALUES('1234567890123','Yalaha',38);
INSERT INTO T_TempEmployee(FIdCardNumber,FName,FAge) VALUES('1234567890124','Tina',26);
INSERT INTO T_TempEmployee(FIdCardNumber,FName,FAge) VALUES('1234567890125','Konkaya',29);
INSERT INTO T_TempEmployee(FIdCardNumber,FName,FAge) VALUES('1234567890126','Fotifa',46);
Union結合
select FNumber,FAge from T_Employee
union
select FIdCardNumber,FAge from T_TempEmployee
union高低的查詢個數和類型必需對應分歧
select FNumber,FAge,FDepartment from T_Employee
union
select FIdCardNumber,FAge ,'暫時工,無部分' from T_TempEmployee
union默許將反復數據去失落。假如不讓他去失落,則用union all
select FName from T_Employee
union all
select FName from T_TempEmployee