본문 바로가기

ORACLE/SQL

set연산자 (union, intersect, minus)

select *

from job_history

order by employee_id;

 

--union (합집합)

select employee_id, job_id

from employees

union

select employee_id, job_id

from job_history;

 

--intersect (교집합)

select employee_id, job_id

from employees

intersect

select employee_id, job_id

from job_history;

 

--minus (차집합)

select employee_id, job_id

from employees

minus

select employee_id, job_id

from job_history;

 

--select 일치

select department_id, to_number(null) location_id, hire_date

from employees

union

select department_id, location_id, to_date(null)

from departments;