求一SQL语句 select name,pwd from Aunion allselect name,pwd from B 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 declare @ta table (name char(1),pwd char(1),id int)insert @ta select '1', '1', 1 insert @ta select '2' , '2' , 3 declare @tb table (name char(1),pwd char(1), email varchar(20))insert @tb select '3' , '3' , '[email protected]' insert @tb select '4' , '4' , '[email protected] 'select isnull(a.name,b.name) as name ,isnull(a.pwd,b.pwd) as pwdfrom @ta afull join @tb b on a.name = b.nameorder by name/*name pwd ---- ---- 1 12 23 34 4*/select name ,pwd from @taunion select name ,pwd from @tb/*name pwd ---- ---- 1 12 23 34 4*/ 那要是要 结果是这样呢结果 name pwd id email1 1 12 2 33 3 [email protected] 4 4 [email protected] select name,pwd,id,email=null from A union all select name,pwd,id=null,email from B 好奇怪的一个问题!真的好奇怪 如何 使用 调用这个存储过程啊 子查询问题????? 为什么我创建存储过程时提醒不能在不能在sysdepends创建对象 使用链接oracle数据库出错,高手来帮忙啊! 关于子查询 数据库完整差异备份问题 问了这么多人都不会 SQLSERVER2000简单问题? 求:winxp下安装sql2005的最低要求 在pl/sql块中 如何动态的执行goto语句 SQL内存使用过少的问题
insert @ta select '1', '1', 1
insert @ta select '2' , '2' , 3
declare @tb table (name char(1),pwd char(1), email varchar(20))insert @tb select '3' , '3' , '[email protected]'
insert @tb select '4' , '4' , '[email protected] 'select isnull(a.name,b.name) as name ,
isnull(a.pwd,b.pwd) as pwd
from @ta a
full join @tb b on a.name = b.name
order by name/*name pwd
---- ----
1 1
2 2
3 3
4 4*/select name ,pwd from @ta
union
select name ,pwd from @tb
/*
name pwd
---- ----
1 1
2 2
3 3
4 4
*/
name pwd id email
1 1 1
2 2 3
3 3 [email protected]
4 4 [email protected]
union all
select name,pwd,id=null,email from B