데이터베이스

[oracle] union all 을 이용하여 두개의 테이블 조회

지승준 2014. 2. 25. 20:41
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
select 
    PHONE 
from ( 
        select 
            replace(replace(PHONE,'-',''),' ''') as PHONE 
        from 
            TB_SIGNATURE 
        where 
            RMV_YN = 'Y' 
 
        union all 
 
        select 
            replace(replace(PHONE,'-',''),' ''') as PHONE 
        from 
            TB_SHOT 
        where 
            RMV_YN = 'Y' 
    ) A 
group by 
    PHONE having isNull(PHONE,'') != '' 
order by 
    PHONE
cs