테이블 a와 b가 있는데 테이블 a에 있는 키값과 일치하는 테이블b의 값을
유니온 한것처럼 두줄로 보여주고싶습니다.
쿼리를 어떻게 작성해야되나요
Comment 2
-
군고구마
2013.11.07 18:34
select *from 테이블a as A with(nolock)inner join 테이블b as B with(nolock)on A.키 = B.키 -
zom6ic
2013.11.07 19:00
이렇게 나오는 걸 원하신게 맞는건가 싶지만... -_-a
select a.*
into #a
from
(
select 'a' as id union all
select 'b' union all
select 'c'
) aselect a.*
into #b
from
(
select 'a' as id union all
select 'b' union all
select 'd'
) aselect a.*
from #A a
left join
(
select * from #Bunion all
select * from #B
) b on a.id = b.iddrop table #a
drop table #b------------------------------------
a
a
b
b
c