当前位置:Gxlcms > 数据库问题 > mysql——多表——合并查询结果

mysql——多表——合并查询结果

时间:2021-07-01 10:21:17 帮助过:4人阅读

table employee ( num int(50), d_id int(50), name varchar(50), age int(50), sex varchar(50), homeadd varchar(50) ); insert into employee values(1,1001,zhangsan,26,nan,beijing); insert into employee values(2,1001,lisi,24,nv,hunan); insert into employee values(3,1002,wangwu,25,nan,jiangsu); insert into employee values(4,1004,aric,15,nan,yingguo); select * from employee; create table department ( d_id int(50), d_name varchar(50), functione varchar(50), address varchar(50) ); insert into department values(1001,keyanbu,yanfachanpin,3lou5hao); insert into department values(1002,shengchanbu,shengchanchanp,5louyiceng); insert into department values(1003,xiaoshoubu,cehuaxiaoshou,1louxiaoshoudating); select * from department;

 

select d_id from department union select d_id from employee;

技术图片

 

 

 

 

 

 

select d_id from department union all select d_id from employee;

技术图片

mysql——多表——合并查询结果

标签:val   arch   alt   wan   cti   ima   UNC   address   res   

人气教程排行