집합 연산자
- 합집합 (union / union all)
union : 중복행 제거
union all : 중복행 포함
select employee_id, job_id
from employees
union
select employee_id, job_id
from job_history;
- 교집합 (intersect)
- 차집합 (minus)
- 공통열이 존재하지 않을 경우
select employee_id, job_id,salary
from employees
union
select employee_id, job_id, 0
from job_history;
select country_id, country_name
from countries
minus
select l.country_id, c.country_name
from locations l
join countries c
on l.country_id = c.country_id
join departments d
on d.location_id = l.location_id;
'학부 정리 > DataBase' 카테고리의 다른 글
[DB] Mysql Workbench Result Grid 사라짐 (0) | 2018.11.29 |
---|---|
[DB공부] 10. DDL (0) | 2018.01.08 |
[DataBase-공부] 9. 행 복제, 열 복제를 해보자 (0) | 2018.01.02 |
[DataBase-공부] 6. 함수를 사용해보자 (2) | 2018.01.01 |
[DataBase-공부] 5. where절을 써서 데이터를 제한해 보자 (0) | 2018.01.01 |