合并两个结果 select id1 from employee ../*id12*/select name from hospital ../*name 王八*/我想变成这样的/*id1 name2 王八*/能行吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 --> 测试数据: @employeedeclare @employee table (id1 int)insert into @employeeselect 2--> 测试数据: @hospitaldeclare @hospital table (name varchar(4))insert into @hospitalselect '王八'select * from @employee cross join @hospital/*id1 name----------- ----2 王八*/ select idl ,'' as name from employee union select '' as idl,name from hospital 上面的SQL好像有问题,你的两个表应该是有关联关系的,还是要用JOIN --> 测试数据: @employeedeclare @employee table (id1 int)insert into @employeeselect 2--> 测试数据: @hospitaldeclare @hospital table (name varchar(4))insert into @hospitalselect '王八'select * from @employee,@hospitalid1 name----------- ----2 王八(1 行受影响) mysql ERROR 2003 求一个查询语句 帮忙分析下数据库压力原因,拜谢 请问主动数据库是个什么技术?MSSQL可以实现么?用什么语言实现?谢谢了 如何将Excel中的数据导入数据库的表中 在线等~~~急急急~~~SQL语句解答~(已经倾家荡产了~~~) 救命哦,大虾们,恢复数据库的时候提示这样子?听我细说 .... 少记录变成多条记录问题,用一条SQL语句应该怎么写? 问题是:从一个表检索出结果同时插到另一个表中提示"into"出错????? 下行取上一行的记录问题 大牛们来分析下,索引为什么没用。 查找ip所在的网段问题
--> 测试数据: @employee
declare @employee table (id1 int)
insert into @employee
select 2
--> 测试数据: @hospital
declare @hospital table (name varchar(4))
insert into @hospital
select '王八'select * from @employee cross join @hospital
/*
id1 name
----------- ----
2 王八
*/
union
select '' as idl,name from hospital
declare @employee table (id1 int)
insert into @employee
select 2
--> 测试数据: @hospital
declare @hospital table (name varchar(4))
insert into @hospital
select '王八'select * from @employee,@hospitalid1 name
----------- ----
2 王八(1 行受影响)