join을 where절에 쓰면 문제점: 보기가 불편해짐(분리되어 있어서)
=>from절에 join조건을 미리 주기(요즘 많이 씀)
세타조인 사용, outer조인 ,inner조인
4번을 이렇게 수정도 가능함
select distinct branch.branch_name, branch.branch_head
from deposit ( inner) join branch on (deposit.branch_name=branch.branch_name)
where balance>=10000
아니면 이렇게도!
select distinct branch.branch_name, branch.branch_head
from deposit ( inner) join branch using (branch_name)
where balance>=10000
보다 이해 빠름,where절 안 봐도 알 수 있기 때문
6번 수정
select client.name, deposit_balance
from client join deposit (using ssn) join branch on(deposit.branch_name=branch.branch_name)
where client.address=branch.address
//관계대수의 표현법과 비슷
'개인공부 > db' 카테고리의 다른 글
9장 (트랜잭션) (0) | 2023.07.20 |
---|---|
8장 (물리적 저장 구조와 인덱스) (0) | 2023.07.20 |
7장 (함수적 종속과 정규화) (0) | 2023.07.20 |
6장 (데이터베이스 설계) (0) | 2023.07.20 |
5장 (무결성과 보안) (0) | 2023.07.20 |