SQL/Oracle
[Oracle] union, union all
에띠
2022. 6. 16. 16:23
728x90
union
- select 결과를 합칠 수 있음
- 합친 결과에서 중복되는 행을 제거
- 컬럼의 개수가 같아야 하고, 각 컬럼의 데이터타입이 같아야 함
union all
- union과 같지만 중복된 행을 제거하지 않음
주문 테이블 조회
select * from tb_order;
union
중복된 행 제거
select ord_userid, ord_regdate from tb_order
union
select ord_userid, ord_regdate from tb_order where ord_price >= 1000000;
union all
중복된 행 제거 x
select ord_userid, ord_regdate from tb_order
union all
select ord_userid, ord_regdate from tb_order where ord_price >= 1000000;
728x90