Cross Join
select * from table1, table2
join์กฐ๊ฑด ์๋ต. ๋ฐ์นด๋ฅดํธ ๊ณฑ.
Natural Join
select * from departments
natural join locations
- ๋ ํ ์ด๋ธ์ ๊ณตํต ์ปฌ๋ผ์ด ์๋ ๊ฒฝ์ฐ ๋ฌต์์ ์ผ๋ก ์กฐ์ธ.
- ์ปฌ๋ผ๋ช ๊ฒน์ณ์ ์๋ฑํ ๊ฒฐ๊ณผ๊ฐ ๋์ฌ ์ ์์ผ๋ ์ฃผ์.
Inner Join
select * from employees e
inner join departments d
on(e.department_id = d.department_id)
innerํค์๋ ์๋ต ๊ฐ๋ฅ.- ANSI ํ์ค ๋ฌธ๋ฒ.
on์ ์ ์กฐ์ธ ์กฐ๊ฑด ์์ฑ.(where์ ์๋ ์์ฑ ๊ฐ๋ฅ)- ์ปฌ๋ผ๋ช
์ด ๊ฐ์ ๊ฒฝ์ฐ ๋ค์๊ณผ ๊ฐ์ด
using์ ์ ์ฌ์ฉํด๋ ๋ฌด๋ฐฉํจ.
select * from employees
inner join departments
using(department_id)
Oracle ๋ฐฉ์
select t1.col1, t1.col2, t2.col1
from table1 t1, table2 t2
where t1.col3 = t2.col3
from์ ์ ํ์๋ก ํ๋ ํ ์ด๋ธ์ ๋ชจ๋ ์ ๋๋ค. (alias์ฌ์ฉ ๊ฐ๋ฅ)- ์ ์ ํ ์กฐ๊ฑด์
where์ ์ ๋ถ์ฌํ๋ค.
Outer Join
select *
from employees e
left outer join departments d
on(e.department_id = d.department_id)
left(right) outer join: ์ผ์ชฝ(์ค๋ฅธ์ชฝ)์ ๋ชจ๋ ํํ์ ๊ฒฐ๊ณผ ํ ์ด๋ธ์ ๋ํ๋จ.full outer join: ์์ชฝ ๋ชจ๋ ๊ฒฐ๊ณผ ํ ์ด๋ธ์ ๋ํ๋จ.outerํค์๋ ์๋ต ๊ฐ๋ฅ.
Self Join
select e.name as '์ฌ์ ์ด๋ฆ', m.name as '์์ฌ ์ด๋ฆ'
from employees e
join employees m
on(e.manager_id = m.employee_id)
- ๊ฐ์ ํ
์ด๋ธ์
alias๋ค๋ฅด๊ฒ ์ฃผ๊ณjoin