여러 SELECT 문의 결과를 하나의 결과 집합으로 결합하는데 사용
SELECT
emp_no,
emp_nm,
birth_de
FROM tb_emp
WHERE birth_de BETWEEN '19600101' AND '19691231'
UNION
SELECT
emp_no,
emp_nm,
birth_de
FROM tb_emp
WHERE birth_de BETWEEN '19700101' AND '19791231'
;
SELECT
emp_no,
emp_nm,
birth_de
FROM tb_emp
WHERE birth_de BETWEEN '19600101' AND '19691231'
UNION ALL
SELECT
emp_no,
emp_nm,
birth_de
FROM tb_emp
WHERE birth_de BETWEEN '19700101' AND '19791231'
;
SELECT
A.emp_no, A.emp_nm, A.addr
, B.certi_cd, C.certi_nm
FROM tb_emp A
JOIN tb_emp_certi B
ON A.emp_no = B.emp_no
JOIN tb_certi C
ON B.certi_cd = C.certi_cd
WHERE C.certi_nm = 'SQLD'
INTERSECT
SELECT
A.emp_no, A.emp_nm, A.addr
, B.certi_cd, C.certi_nm
FROM tb_emp A
JOIN tb_emp_certi B
ON A.emp_no = B.emp_no
JOIN tb_certi C
ON B.certi_cd = C.certi_cd
WHERE A.addr LIKE '%용인%';
SELECT emp_no, emp_nm, sex_cd, dept_cd FROM tb_emp
MINUS
SELECT emp_no, emp_nm, sex_cd, dept_cd FROM tb_emp WHERE dept_cd = '100001'
MINUS
SELECT emp_no, emp_nm, sex_cd, dept_cd FROM tb_emp WHERE dept_cd = '100004'
MINUS
SELECT emp_no, emp_nm, sex_cd, dept_cd FROM tb_emp WHERE sex_cd = '1'
;