본문 바로가기

DB

[MySQL] UNION ALL

UNION (DISTINCT)

 :  쿼리의 결과를 합친다. 중복된 ROW는 제거한다.

 

select * from table_1
union distinct
select * from table_2;

UNION ALL   

: 중복 제거 하지 않는다.

select * from table_1
union all
select * from table_2;

UNION ALL 은 중복제거를 하지 않으므로 UNION보다 실행 속도가 빠르다.