select * into #t from
(select 1 id, '反循环阀' 部件名称
union
select 2, '多流测试器'
union
select 3, '上封隔器'
union
select 4, '下封隔器'
union
select 5, '筛管') Aselect A.* from
(select 部件名称, 部件规格, 部件深度 from 表1
union all
select '上封隔器', null, 上封隔器 from 表2
union all
select '下封隔器', null, 下封隔器 from 表2
) A left join #t B on A.部件名称 = B.部件名称
where A.部件深度 is not null
order by B.iddrop table #t
(select 1 id, '反循环阀' 部件名称
union
select 2, '多流测试器'
union
select 3, '上封隔器'
union
select 4, '下封隔器'
union
select 5, '筛管') Aselect A.* from
(select 部件名称, 部件规格, 部件深度 from 表1
union all
select '上封隔器', null, 上封隔器 from 表2
union all
select '下封隔器', null, 下封隔器 from 表2
) A left join #t B on A.部件名称 = B.部件名称
where A.部件深度 is not null
order by B.iddrop table #t
还稍微有一点不同就是:表一是这样部件名称 部件规格 部件深度
-------------------- -------------------- ---------
多流测试器 127 3185.34
反循环阀 NULL NULL
筛管 NULL NULL
要求在表3中,也得到这样的结果
你的查询后,就变成了
部件名称 部件规格 部件深度
-------------------- -------------------- ---------
多流测试器 127 3185.34这样了