관리 메뉴

moozi

sql join 문법 본문

TIS_2020/빅데이터2020_1기

sql join 문법

moozi 2020. 9. 23. 15:37

-- 직원의 부서명 구하기
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;

'TIS_2020 > 빅데이터2020_1기' 카테고리의 다른 글

oracle jdbc연결테스트  (0) 2020.09.29
오라클연습문제풀이  (0) 2020.09.29
sql join 문법  (0) 2020.09.23
sysdba로그인하기  (0) 2020.09.22
오라클 한글 깨짐  (0) 2020.09.22
ANSI SQL inner join  (0) 2020.09.22
0 Comments
댓글쓰기 폼