์กฐ์ธ(JOIN)

Joy๐ŸŒฑยท2023๋…„ 1์›” 12์ผ
0

๐Ÿš Oracle

๋ชฉ๋ก ๋ณด๊ธฐ
4/11
post-thumbnail

๐Ÿ’โ€โ™€๏ธ ์กฐ์ธ(JOIN)์ด๋ž€,
ํ•œ ๊ฐœ ์ด์ƒ์˜ ํ…Œ์ด๋ธ”์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์กฐํšŒํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์œผ๋กœ, ์ˆ˜ํ–‰ ๊ฒฐ๊ณผ๋Š” ํ•˜๋‚˜์˜ Result Set์œผ๋กœ ์ถœ๋ ฅ


๐Ÿ˜ˆ Warning

JOIN์„ ์‚ฌ์šฉํ•  ๋•Œ, '์˜ค๋ผํด ์ „์šฉ ๊ตฌ๋ฌธ'๊ณผ 'ANSI ํ‘œ์ค€ ๊ตฌ๋ฌธ'์œผ๋กœ ๋‚˜๋‰˜๋ฉฐ, ๋‘˜์˜ ๊ธฐ๋Šฅ์€ ๋™์ผํ•˜๋‚˜ ๋ฌธ๋ฒ•์˜ ์ฐจ์ด๊ฐ€ ์žˆ์Œ

  • ์˜ค๋ผํด ์ „์šฉ ๊ตฌ๋ฌธ
    : FROM์ ˆ์— ',๏ผ‡๋กœ ๊ตฌ๋ถ„ํ•˜์—ฌ ํ•ฉ์น˜๊ฒŒ ๋  TABLE๋ช…์„ ๊ธฐ์ˆ ํ•˜๊ณ , WHERE์ ˆ์— ํ•ฉ์น˜๊ธฐ์— ์‚ฌ์šฉํ•  ์ปฌ๋Ÿผ๋ช…์„ ๋ช…์‹œ
SELECT
		EMP_ID
    ,	EMP_NAME
    ,	DEPT_CODE
    ,	DEPT_TITLE
    FROM EMPLOYEE
    ,    DEPARTMENT
   WHERE DEPT_CODE = DEPT_ID;
  • ANSI ํ‘œ์ค€ ๊ตฌ๋ฌธ
    : FROM์ ˆ ๋‹ค์Œ์— JOIN์„ ์ž…๋ ฅ ํ›„ ํ•ฉ์น˜๊ฒŒ ๋  TABLE๋ช…์„ ๊ธฐ์ˆ ํ•˜๊ณ , ์†Œ๊ด„ํ˜ธ ์•ˆ์— ์ปฌ๋Ÿผ๋ช…์„ ๋ช…์‹œ
    • ์—ฐ๊ฒฐ์— ์‚ฌ์šฉํ•˜๋ ค๋Š” ์ปฌ๋Ÿผ๋ช…์ด ๊ฐ™์€ ๊ฒฝ์šฐ USING()์„ ์‚ฌ์šฉ
    • ์—ฐ๊ฒฐ์— ์‚ฌ์šฉํ•˜๋ ค๋Š” ์ปฌ๋Ÿผ๋ช…์ด ๋‹ค๋ฅธ ๊ฒฝ์šฐ ON()์„ ์‚ฌ์šฉ)
SELECT
		EMP_ID
    ,	EMP_NAME
    ,	DEPT_CODE
    ,	DEPT_TITLE
    FROM EMPLOYEE
    JOIN DEPARTMENT ON(DEPT_CODE = DEPT_ID);

๐Ÿ‘‰ ANSI ํ‘œ์ค€ ๊ตฌ๋ฌธ์ด ๋‹ค๋ฅธ SQL์–ธ์–ด์™€ ๋ฌธ๋ฒ•์ด ์ผ์น˜ํ•˜๋ฏ€๋กœ ANSI ํ‘œ์ค€ ๊ตฌ๋ฌธ์„ ์ˆ™์ง€ํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๋” ์ข‹์Œ


๐Ÿ‘€ JOIN์˜ ๊ธฐ๋ณธ ๋ฌธ๋ฒ•

๐Ÿ‘‰ ์˜ค๋ผํด ์ „์šฉ ๊ตฌ๋ฌธ

[1] ์—ฐ๊ฒฐ์— ์‚ฌ์šฉํ•  ๋‘ ์ปฌ๋Ÿผ๋ช…์ด ๋‹ค๋ฅธ ๊ฒฝ์šฐ

SELECT
        EMP_ID
    ,   EMP_NAME
    ,   DEPT_CODE
    ,   DEPT_TITLE	>>> ์–˜๋งŒ DEPARTMENT ํ…Œ์ด๋ธ”์— ์žˆ๋Š” ์ปฌ๋Ÿผ
   FROM EMPLOYEE
    ,   DEPARTMENT 
  WHERE DEPT_CODE = DEPT_ID;

[2] ์—ฐ๊ฒฐ์— ์‚ฌ์šฉํ•  ๋‘ ์ปฌ๋Ÿผ๋ช…์ด ๊ฐ™์€ ๊ฒฝ์šฐ

: ํ…Œ์ด๋ธ”๋ช…์„ ์ง€์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ์—ด์˜ ์ •์˜๊ฐ€ ์• ๋งคํ•˜๋‹ค๋Š” ์˜ค๋ฅ˜ ๋ฐœ์ƒ

SELECT
        EMP_ID
    ,   EMP_NAME
    ,   EMPLOYEE.JOB_CODE	>>> JOB_CODE : ๋‘ ํ…Œ์ด๋ธ”์— ๋ชจ๋‘ ์žˆ๋Š” ์ปฌ๋Ÿผ 
    ,   JOB_NAME
    FROM EMPLOYEE
    ,   JOB
    WHERE EMPLOYEE.JOB_CODE = JOB.JOB_CODE; >>> ํ…Œ์ด๋ธ”๋ช…์„ ์ง€์ •(๋ช…์‹œ)ํ•ด์•ผํ•จ

[3] ํ…Œ์ด๋ธ”๋ช…์— ๋ณ„์นญ์„ ์‚ฌ์šฉํ•ด์„œ ์ˆ˜์ •

SELECT
        E.EMP_ID
    ,   E,EMP_NAME
    ,   E.JOB_CODE 
    ,   J.JOB_NAME
    FROM EMPLOYEE E		>>> EMPLOYEE ํ…Œ์ด๋ธ”์˜ ๋ณ„์นญ E
    ,   JOB J			>>> JOB ํ…Œ์ด๋ธ”์˜ ๋ณ„์นญ J
    WHERE E.JOB_CODE = J.JOB_CODE; 

๐Ÿ‘‰ ANSI ํ‘œ์ค€ ๊ตฌ๋ฌธ

[1] ์—ฐ๊ฒฐ์— ์‚ฌ์šฉํ•  ์ปฌ๋Ÿผ๋ช…์ด ๊ฐ™์€ ๊ฒฝ์šฐ, USING(์ปฌ๋Ÿผ๋ช…)์„ ์‚ฌ์šฉ (ON ์‚ฌ์šฉO)

SELECT
        EMP_ID
    ,   EMP_NAME
    ,   JOB_CODE 
    ,   JOB_NAME
    FROM EMPLOYEE
    JOIN JOB USING(JOB_CODE);

[2] ์—ฐ๊ฒฐ์— ์‚ฌ์šฉํ•  ์ปฌ๋Ÿผ๋ช…์ด ๋‹ค๋ฅธ ๊ฒฝ์šฐ, ON()์„ ์‚ฌ์šฉ (USING ์‚ฌ์šฉX)

SELECT
        EMP_ID
    ,   EMP_NAME
    ,   DEPT_CODE
    ,   DEPT_TITLE
    FROM EMPLOYEE
    JOIN DEPARTMENT ON(DEPT_CODE = DEPT_ID);

[3] ์ปฌ๋Ÿผ๋ช…์ด ๊ฐ™์€ ๊ฒฝ์šฐ์—๋„ ON์œผ๋กœ ์ž‘์„ฑ ๊ฐ€๋Šฅ

SELECT
        E.EMP_ID
    ,   E.EMP_NAME
    ,   E.JOB_CODE 
    ,   J.JOB_NAME
    FROM EMPLOYEE E 
    JOIN JOB J ON(E.JOB_CODE = J.JOB_CODE);	>>> ์–ด๋–ค ํ…Œ์ด๋ธ”์˜ ์ปฌ๋Ÿผ์ธ์ง€ ๋ช…์‹œ

๐Ÿ‘€ INNER JOIN & OUTER JOIN

๐Ÿ’โ€โ™€๏ธ INNER JOIN & OUTER JOIN์ด๋ž€,
๋‘ ๊ฐœ ์ด์ƒ์˜ ํ…Œ์ด๋ธ”์„ ์กฐ์ธํ•  ๋•Œ, ์ผ์น˜ํ•˜๋Š” ๊ฐ’์ด ์—†๋Š” ํ–‰์€ JOIN์—์„œ ์ œ์™ธํ•˜๋Š” ๊ฒƒ์„ INNER JOIN์ด๋ผ๊ณ  ํ•˜๋ฉฐ, ๋ช…์‹œ์ ์œผ๋กœ ์‚ฌ์šฉํ•˜์ง€ ์•Š์„ ์‹œ์—๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ INNER JOIN
ํ•˜์ง€๋งŒ ์ผ์น˜ํ•˜์ง€ ์•Š์€ ๊ฐ’ ๋˜ํ•œ JOIN์— ํฌํ•จ์‹œํ‚ฌ ์ˆ˜๋„ ์žˆ๋Š”๋ฐ, ์ด๊ฒƒ์„ OUTER JOIN์ด๋ผ๊ณ  ํ•˜๋ฉฐ, ๋ฐ˜๋“œ์‹œ OUTER JOIN์ž„์„ ๋ช…์‹œํ•ด์•ผํ•จ


๐Ÿ™‹โ€ ์ž ๊น ! OUTER JOIN์€ ์–ด๋–ป๊ฒŒ ๋ช…์‹œํ•˜๋‚˜์š”?

  • LEFT OUTER JOIN : ํ•ฉ์น˜๊ธฐ์— ์‚ฌ์šฉํ•œ ๋‘ ํ…Œ์ด๋ธ” ์ค‘ ์™ผํŽธ์— ๊ธฐ์ˆ ๋œ ํ…Œ์ด๋ธ”์„ ๊ธฐ์ค€์œผ๋กœ JOIN
  • RIGHT OUTER JOIN : ํ•ฉ์น˜๊ธฐ์— ์‚ฌ์šฉํ•œ ๋‘ ํ…Œ์ด๋ธ” ์ค‘ ์˜ค๋ฅธํŽธ์— ๊ธฐ์ˆ ๋œ ํ…Œ์ด๋ธ”์„ ๊ธฐ์ค€์œผ๋กœ JOIN
  • FULL OUTER JOIN : ํ•ฉ์น˜๊ธฐ์— ์‚ฌ์šฉํ•œ ๋‘ ํ…Œ์ด๋ธ”์ด ๊ฐ€์ง„ ๋ชจ๋“  ํ–‰์„ ๊ฒฐ๊ณผ์— ํฌํ•จํ•˜์—ฌ JOIN

1) LEFT OUTER JOIN

โ—ผ ANSI

SELECT
        EMP_NAME
    ,   DEPT_TITLE
    FROM EMPLOYEE
--LEFT OUTER JOIN DEPARTMENT ON(DEPT_CODE = DEPT_ID);	>>> EMPLOYEE ๊ธฐ์ค€์œผ๋กœ JOIN 			
LEFT JOIN DEPARTMENT ON(DEPT_CODE = DEPT_ID);	>>> ์œ„์™€ ๋™์ผํ•œ ์ถœ๋ ฅ (OUTER ์ƒ๋žต ๊ฐ€๋Šฅ)

>>> DEPT_TITLE์ด NULL๊ฐ’(์ผ์น˜ํ•˜์ง€ ์•Š๋Š” ํ–‰)์ธ ํ•˜๋™์šด, ์ด์˜ค๋ฆฌ๋„ ์ถœ๋ ฅ

โ—ผ ORACLE

SELECT
        EMP_NAME
    ,   DEPT_TITLE
    FROM EMPLOYEE
    ,   DEPARTMENT
   WHERE DEPT_CODE = DEPT_ID(+); 
    >>> DEPARTMENT ํ…Œ์ด๋ธ” ์ชฝ์— (+)๋ฅผ ๋ถ™์—ฌ์•ผ EMPLOYEE ๊ธฐ์ค€์œผ๋กœ JOINํ•˜๊ฒ ๋‹ค๋Š” ์˜๋ฏธ๊ฐ€ ๋จ

2) RIGHT OUTER JOIN

โ—ผ ANSI

SELECT
        EMP_NAME
    ,   DEPT_TITLE
    FROM EMPLOYEE
--RIGHT OUTER JOIN DEPARTMENT ON(DEPT_CODE = DEPT_ID);	>>> DEPARTMENT ๊ธฐ์ค€์œผ๋กœ JOIN												
RIGHT JOIN DEPARTMENT ON(DEPT_CODE = DEPT_ID); 	>>> ์œ„์™€ ๋™์ผํ•œ ์ถœ๋ ฅ (OUTER ์ƒ๋žต ๊ฐ€๋Šฅ)

>>> EMP_NAME์ด NULL๊ฐ’(์ผ์น˜ํ•˜์ง€ ์•Š๋Š” ํ–‰)์ธ ๋งˆ์ผ€ํŒ…๋ถ€, ๊ตญ๋‚ด์˜์—…๋ถ€, ํ•ด์™ธ์˜์—… 3๋ถ€๋„ ์ถœ๋ ฅ

โ—ผ ORACLE

SELECT
        EMP_NAME
    ,   DEPT_TITLE
    FROM EMPLOYEE
    ,   DEPARTMENT
   WHERE DEPT_CODE(+) = DEPT_ID;
    >>> EMPLOYEE ํ…Œ์ด๋ธ” ์ชฝ์— (+)๋ฅผ ๋ถ™์—ฌ์•ผ DEPARTMENT ๊ธฐ์ค€์œผ๋กœ JOINํ•˜๊ฒ ๋‹ค๋Š” ์˜๋ฏธ๊ฐ€ ๋จ

3) FULL OUTER JOIN

โ—ผ ANSI

SELECT
        EMP_NAME
    ,   DEPT_TITLE
    FROM EMPLOYEE
--FULL OUTER JOIN DEPARTMENT ON(DEPT_CODE = DEPT_ID);
FULL JOIN DEPARTMENT ON(DEPT_CODE = DEPT_ID); >>> ์œ„์™€ ๋™์ผํ•œ ์ถœ๋ ฅ (OUTER ์ƒ๋žต ๊ฐ€๋Šฅ)

>>> ํ•˜๋™์šด, ์ด์˜ค๋ฆฌ, ๋งˆ์ผ€ํŒ…๋ถ€, ๊ตญ๋‚ด์˜์—…๋ถ€, ํ•ด์™ธ์˜์—… 3๋ถ€ ๋ชจ๋‘ ์ถœ๋ ฅ๋จ (์ผ์น˜ํ•˜๋Š” ๊ฐ’์ด ์—†๋Š” ํ–‰๋„ ๋ชจ๋‘ ์ถœ๋ ฅ)

โ—ผ ORACLE

ORACLE ์ „์šฉ ๊ตฌ๋ฌธ์—์„œ๋Š” FULL OUTER JOIN ๋ถˆ๊ฐ€

SELECT
        EMP_NAME
    ,   DEPT_TITLE
    FROM EMPLOYEE
    ,   DEPARTMENT
   WHERE DEPT_CODE(+) = DEPT_ID(+); -- 'outer-join๋œ ํ…Œ์ด๋ธ”์€ 1๊ฐœ๋งŒ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค' ์˜ค๋ฅ˜

๐Ÿ‘€ CROSS JOIN

๐Ÿ’โ€โ™€๏ธ CROSS JOIN์ด๋ž€,
์นดํ…Œ์ด์…˜๊ณฑ(Cartensian projuct)์ด๋ผ๊ณ ๋„ ํ•˜๋ฉฐ, ์กฐ์ธ๋˜๋Š” ํ…Œ์ด๋ธ”์˜ ๊ฐ ํ–‰๋“ค์ด ๋ชจ๋‘ ๋งคํ•‘๋œ ๋ฐ์ดํ„ฐ๊ฐ€ ๊ฒ€์ƒ‰๋˜๋Š” ์กฐ์ธ ๋ฐฉ๋ฒ•์œผ๋กœ, ๊ฒ€์ƒ‰๋˜๋Š” ๋ฐ์ดํ„ฐ ์ˆ˜๋Š” (ํ–‰์˜ ์ปฌ๋Ÿผ์ˆ˜) x (ํ–‰์˜ ์ปฌ๋Ÿผ์ˆ˜)

  • ๋ชจ๋“  ํ–‰์ด ์ถœ๋ ฅ๋จ

SELECT
        EMP_NAME
    ,   DEPT_TITLE
    FROM EMPLOYEE
CROSS JOIN DEPARTMENT;

๐Ÿ‘€ NON EQUAL JOIN

๐Ÿ’โ€โ™€๏ธ NON EQUAL JOIN์ด๋ž€,
์ง€์ •ํ•œ ์ปฌ๋Ÿผ ๊ฐ’์ด ์ผ์น˜ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์•„๋‹Œ, ๊ฐ’์˜ ๋ฒ”์œ„์— ํฌํ•จ๋˜๋Š” ํ–‰๋“ค์„ ์—ฐ๊ฒฐํ•˜๋Š” ๋ฐฉ์‹


โ—ผ ANSI

SELECT
        EMP_NAME
    ,   SALARY
    ,   E.SAL_LEVEL "EMPLOYEE์˜ SAL_LEVEL"
    ,   S.SAL_LEVEL "SAL_GRADE์˜ SAL_LEVEL"
    FROM EMPLOYEE E
    JOIN SAL_GRADE S ON(SALARY BETWEEN MIN_SAL AND MAX_SAL); 
    >>> SALARY ๊ฐ’์ด ์–ด๋–ค MIN_SAL๊ณผ MAX_SAL์‚ฌ์ด์— ์žˆ์„๋•Œ ๋‘ ํ…Œ์ด๋ธ”์˜ ์—ฐ๊ฒฐ์ง€์ ์„ ์ถœ๋ ฅ
    >>> (S1, S2, S3, S4, S5, S6 ์ค‘ ์ผ์น˜๋˜๋Š” ๊ฒƒ)

โ—ผ ORACLE

SELECT
        EMP_NAME
    ,   SALARY
    ,   E.SAL_LEVEL "EMPLOYEE์˜ SAL_LEVEL"
    ,   S.SAL_LEVEL "SAL_GRADE์˜ SAL_LEVEL"
    FROM EMPLOYEE E
    ,   SAL_GRADE S
   WHERE SALARY BETWEEN MIN_SAL AND MAX_SAL;
   >>> ์œ„์™€ ๋™์ผํ•œ ์ถœ๋ ฅ

๐Ÿ‘€ SELF JOIN

๐Ÿ’โ€โ™€๏ธ SELF JOIN์ด๋ž€,
๊ฐ™์€ ํ…Œ์ด๋ธ”์„ ์กฐ์ธํ•˜๋Š” ๊ฒฝ์šฐ, ์ž๊ธฐ ์ž์‹ ๊ณผ ์กฐ์ธ์„ ๋งบ๋Š” ๊ฒƒ


โ—ผ ANSI

SELECT
        E1.EMP_ID
    ,   E1.EMP_NAME ์‚ฌ์›๋ช…
    ,   E1.MANAGER_ID
    ,   E2.EMP_NAME ๊ด€๋ฆฌ์ž๋ช…
    FROM EMPLOYEE E1
    JOIN EMPLOYEE E2 ON(E1.MANAGER_ID = E2.EMP_ID);
    	>>> EMPLOYEE ํ…Œ์ด๋ธ”์— EMPLOYEE ํ…Œ์ด๋ธ”์„ ํ•œ๋ฒˆ ๋” JOIN (๋Œ€์‹  ๋ช…์‹œ ํ•„์ˆ˜)

โ—ผ ORACLE

SELECT
        E1.EMP_ID
    ,   E1.EMP_NAME ์‚ฌ์›๋ช…
    ,   E1.MANAGER_ID
    ,   E2.EMP_NAME ๊ด€๋ฆฌ์ž๋ช…
    FROM EMPLOYEE E1
    ,    EMPLOYEE E2    
    WHERE E1.MANAGER_ID = E2.EMP_ID;	>>> ๋งค๋‹ˆ์ € ID๊ฐ€ ์žˆ๋Š” ์‚ฌ๋žŒ์— ํ•œํ•ด์„œ(INNER JOIN์€ NULL๊ฐ’ ์ œ์™ธ) ์ถœ๋ ฅ

๐Ÿ‘€ ๋‹ค์ค‘ JOIN

๐Ÿ’โ€โ™€๏ธ ๋‹ค์ค‘ JOIN์ด๋ž€,
N๊ฐœ์˜ ํ…Œ์ด๋ธ”์„ ์กฐํšŒํ•  ๋•Œ ์‚ฌ์šฉ (๋‹ค์ค‘ JOIN์˜ ๊ฒฝ์šฐ, ์กฐ์ธ์˜ ์ˆœ์„œ๊ฐ€ ์ค‘์š”)


โ—ผ ANSI

SELECT
        EMP_NAME ์ด๋ฆ„ 	 -- FROM EMPLOYEE
    ,   DEPT_TITLE ๋ถ€์„œ๋ช… -- FROM DEPARTMENT
    ,   LOCAL_NAME ์ง€์—ญ๋ช… -- FROM LOCATION   
    					 >>> ๊ฐ๊ฐ ๋‹ค๋ฅธ ํ…Œ์ด๋ธ”์˜ ์ปฌ๋Ÿผ๋“ค
    FROM EMPLOYEE
    JOIN DEPARTMENT ON(DEPT_CODE = DEPT_ID)
    JOIN LOCATION ON(LOCATION_ID = LOCAL_CODE); >>> ์ด ๊ตฌ๋ฌธ์„ ์œ„๋กœ ์˜ฌ๋ ค ์ˆœ์„œ๋ฅผ ๋ฐ”๊พธ๋ฉด JOIN ๋ถˆ๊ฐ€
    											>>> JOIN ๊ตฌ๋ฌธ ๋‚˜์—ด ์ˆœ์„œ์— ์œ ์˜

โ—ผ ORACLE

SELECT
        EMP_NAME ์ด๋ฆ„ -- FROM EMPLOYEE
    ,   DEPT_TITLE ๋ถ€์„œ๋ช… -- FROM DEPARTMENT
    ,   LOCAL_NAME ์ง€์—ญ๋ช… -- FROM LOCATION
    FROM EMPLOYEE
    ,    DEPARTMENT
    ,    LOCATION
    WHERE DEPT_CODE = DEPT_ID
    AND LOCATION_ID = LOCAL_CODE; >>> ORACLE ์ „์šฉ ๊ตฌ๋ฌธ์€ ํ…Œ์ด๋ธ”๋ช… ์„œ์ˆ  ์ˆœ์„œ์™€ ๊ด€๊ณ„ X
    						      >>> WHERE ์กฐ๊ฑด๋ฌธ์˜ ์ˆœ์„œ๊ฐ€ ๋ฐ”๋€Œ์–ด๋„ ๋ฌธ์ œ X

๐Ÿ‘‰ ์ง๊ธ‰์ด ๋Œ€๋ฆฌ์ด๋ฉด์„œ ์•„์‹œ์•„ ์ง€์—ญ์— ๊ทผ๋ฌดํ•˜๋Š” ์ง์›์˜ ์ด๋ฆ„, ์ง๊ธ‰๋ช…, ๋ถ€์„œ๋ช…, ๊ทผ๋ฌด์ง€์—ญ๋ช… ์กฐํšŒ

โ—ผ ANSI

SELECT
        EMP_NAME ์ด๋ฆ„
    ,   JOB_NAME ์ง๊ธ‰๋ช…
    ,   DEPT_TITLE ๋ถ€์„œ๋ช…
    ,   LOCAL_NAME ๊ทผ๋ฌด์ง€์—ญ๋ช…
    FROM EMPLOYEE E
    JOIN JOB J ON (E.JOB_CODE = J.JOB_CODE) 
    >>> ๋Œ€์‹  JOIN JOB USING(JOB_CODE)๋กœ๋„ ํ•  ์ˆ˜ ์žˆ์Œ (๊ฐ™์€ ์ปฌ๋Ÿผ๋ช…์ผ ๊ฒฝ์šฐ, USING ์‚ฌ์šฉ ๊ฐ€๋Šฅ)
    JOIN DEPARTMENT ON (DEPT_CODE = DEPT_ID)
    JOIN LOCATION ON(LOCATION_ID = LOCAL_CODE)
   WHERE JOB_NAME = '๋Œ€๋ฆฌ'
     AND LOCAL_NAME LIKE 'ASIA%';

โ—ผ ORACLE

SELECT
        E.EMP_NAME ์ด๋ฆ„
    ,   J.JOB_NAME ์ง๊ธ‰๋ช…
    ,   D.DEPT_TITLE ๋ถ€์„œ๋ช…
    ,   L.LOCAL_NAME ๊ทผ๋ฌด์ง€์—ญ๋ช…
    FROM EMPLOYEE E
    ,    JOB J
    ,    DEPARTMENT D
    ,    LOCATION L
   WHERE E.JOB_NAME = J.JOB_NAME
     AND E.DEPT_CODE = D.DEPT_ID
     AND D.LOCATION_ID = L.LOCAL_CODE
     AND JOB_NAME = '๋Œ€๋ฆฌ'
     AND LOCAL_NAME LIKE 'ASIA%';

profile
Tiny little habits make me

0๊ฐœ์˜ ๋Œ“๊ธ€