[데이터 베이스]10.집합

손영민's avatar
Mar 09, 2025
[데이터 베이스]10.집합
union all
 
 
-- 1. union all (통으로 붙인다 컴럼갯수가 동일 해야한다 select sum(sal), deptno from emp where deptno =10 union all select sum(sal), deptno from emp where deptno =20 union all select sum(sal), deptno from emp where deptno =30 union all select sum(sal), null from emp;
 
-- 2. union (합집합 - 중복을 제거하고 통으로 붙인다(연산이 든다)) select * from dept where deptno > 10 -- 20, 30, 40 union select * from dept where deptno < 30; -- 10, 20
 
-- 3. intersect(교집합 - 중복을 붙인다(툴이 오류난거 처럼 보임)) select * from dept where deptno > 10 -- 20, 30, 40 intersect select * from dept where deptno < 30; -- 10, 20
 
-- 4. EXCEPT(차집합 - (툴이 오류난거 처럼 보임)) select * from dept where deptno > 10 -- 20, 30, 40 except select * from dept where deptno < 30; -- 10, 20
 
Share article

sson17