select id,working from AAA.dbo.id_table where status='A'
select id,working from BBB.dbo.id_table where status='A'
select id,working from CCC.dbo.id_table where status='A'
AAA,BBB,CCC 데이타베이스명
이렇게 다른 테이타 베이스에서 데이블 내용을 불러 올려고 합니다...
각 테이블에서의 저장된 값을 전부 불러오려고 합니다...
단 id 값이 중복된 값은 하나만 불러 오려고합니다.
방법이 있나요???
Comment 4
-
neonics
2013.03.25 13:21
-
삼미슈퍼스타
2013.03.25 13:50
select id,working from AAA.dbo.id_table a where a.status='A'
UNIONselect id,working from BBB.dbo.id_table b where b.status='A'
UNIONselect id,working from CCC.dbo.id_table c where c.status='A'
이렇게 사용했습니다...
-
처리짱
2013.03.25 15:14
select id, max(working)
(
select id,working from AAA.dbo.id_table a where a.status='A'
UNION
select id,working from BBB.dbo.id_table b where b.status='A'
UNION
select id,working from CCC.dbo.id_table c where c.status='A'
) as a
group by id
혹시 이거 일까요..
-
삼미슈퍼스타
2013.03.25 16:56
select id, max(working) from
(
select id,working from AAA.dbo.id_table a where a.status='A'
UNION
select id,working from BBB.dbo.id_table b where b.status='A'
UNION
select id,working from CCC.dbo.id_table c where c.status='A'
) as a
group by id
잘됩니다... 너무 감사합니다...
max를 주시든 min을 주시든 하면되실듯..?