- INNER JOIN (1개 테이블)
SELECT * FROM
MEMBERS M
INNER JOIN NOTICES N ON M.MID = N.WRITER
- INNER JOIN (다중 테이블)
SELECT * FROM
MEMBERS M
INNER JOIN NOTICES N ON M.MID = N.WRITER
INNER JOIN COMMENTS C ON N.CODE = N.NOTICE_CODE
- OUTER JOIN (LEFT : 왼쪽 테이블 컬럼 기준, RIGHT : 오른쪽 테이블 컬럼 기준, FULL : 기준없이 모든 컬럼)
SELECT * FROM
MEMBERS M
LEFT OUTER JOIN NOTICES N ON M.MID = N.WRITER
- OUTER JOIN (테이블 기준 설정)
SELECT * FROM
MEMBERS M
RIGHT OUTER JOIN NOTICES N ON M.MID = N.WRITER
LEFT OUTER JOIN COMMENTS C ON N.CODE = N.NOTICE_CODE
SELECT N.CODE, N.TITLE, M.NAME WRITER, COUNT(C.CODE) FROM
MEMBERS M
RIGHT OUTER JOIN NOTICES N ON M.MID = N.WRITER
LEFT OUTER JOIN COMMENTS C ON N.CODE = N.NOTICE_CODE
GROUP BY N.CODE, N.TITLE, M.NAME
- SELF JOIN (자기 자신의 테이블을 조인)
SELECT B.NAME "상사명", M.NAME 사원명 FROM
MEMBERS B RIGHT OUTER JOIN MEMBERS M
ON B.MID = M.BOSS