-- 직원의 부서명 구하기
select * from employees;
select * from departments;
-- inner join. oracle 문법
select employees.emp_name, departments.department_name
from employees, departments
where employees.department_id=departments.department_id;
select e.emp_name, d.department_name
from employees e, departments d
where e.department_id=d.department_id;
select e.emp_name, d.department_name
from employees e, departments d
where e.department_id=d.department_id
and e.salary> 20000;
-- inner join 표준문법(ANSI SQL)
select employees.emp_name, departments.department_name
from employees inner join departments
on employees.department_id=departments.department_id;
select e.emp_name, d.department_name
from employees e inner join departments d
on e.department_id=d.department_id;
select e.emp_name, d.department_name
from employees e inner join departments d
on e.department_id=d.department_id
where e.salary>2000;
-- 사원명, 부서명, 직책명
select * from employees;
select * from departments;
select * from jobs;
-- oracle 문법
select e.emp_name, d.department_name, j.job_title
from employees e ,departments d, jobs j
where e.department_id=d.department_id
and e.job_id=j.job_id;
-- ansi sql
select e.emp_name, d.department_name, j.job_title
from employees e inner join departments d
on e.department_id=d.department_id
inner join jobs j -- 이미 기술된 테이블은 적지 않는다.
on e.job_id=j.job_id;