联合结果集新建临时工数据表复制代码代码如下:CREATETABLET_TempEmployee(FIdCardNumberVARCHAR(20),FNameVARCHAR(20),FAgeint,PRIMARYKEY(FIdCardNumber));INSERTINTOT_TempEmployee(FIdCardNumber,FName,FAge)VALUES('1234567890121','Sarani',33);INSERTINTOT_TempEmployee(FIdCardNumber,FName,FAge)VALUES('1234567890122','Tom',26);INSERTINTOT_TempEmployee(FIdCardNumber,FName,FAge)VALUES('1234567890123','Yalaha',38);INSERTINTOT_TempEmployee(FIdCardNumber,FName,FAge)VALUES('1234567890124','Tina',26);INSERTINTOT_TempEmployee(FIdCardNumb
联合结果集
新建临时工数据表
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联合
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
声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!