注册 登录
编程论坛 SQL Server论坛

求教,怎么实现

lanfu 发布于 2012-12-16 13:50, 314 次点击
查询两个表,要求临时表为表3的样子,怎么实现,谢谢
表1

si_no  n1  N2

11     pq  12
11     fa  23


表2
si_no  P1   p2
11     ds   12
11     21   13
11     ds   23

表3

si_no  n1   n2   p1   p2
11     pq   12   NULl NULL
11     fa   23   null null
11     null null ds   12
11     null null 21   13
11     null null ds   23
1 回复
#2
cnfarer2012-12-16 18:52
select n1,n2,null as p1,null as p2 from 表1
union all
select null as n1,null as n2,p1,p2 from 表2
1