[ORACLE] JOIN

๊ฐ•์ง€์˜ยท2023๋…„ 2์›” 16์ผ
0

SQL

๋ชฉ๋ก ๋ณด๊ธฐ
11/20
post-custom-banner

๐Ÿ“š JOIN

๊ฐ ํ…Œ์ด๋ธ” ๊ฐ„์— ๊ณตํ†ต๋œ ์ปฌ๋Ÿผ(์กฐ๊ฑด)์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ํ•ฉ์ณ ํ‘œํ˜„ํ•œ ๊ฒƒ
JOIN์—๋Š” ํฌ๊ฒŒ INNER JOIN, OUTER JOIN์ด ์žˆ๋‹ค.

๐Ÿ“‘ JOIN

โฆ SELECT FROM

์˜ค๋ผํด ์กฐ์ธ์€ ์กฐ์ธ ์ปฌ๋Ÿผ ์กฐ๊ฑด์„ WHERE์ ˆ์— ์ž‘์„ฑํ•˜๋ฉด ๋œ๋‹ค.

SELECT a.์ปฌ๋Ÿผ๋ช…1, a.์ปฌ๋Ÿผ๋ช…2, b.์ปฌ๋Ÿผ๋ช…3
  FROM ๋ฉ”์ธ ํ…Œ์ด๋ธ”๋ช… a		
     , ์กฐ์ธ ํ…Œ์ด๋ธ”๋ช… b		
 WHERE a.์ปฌ๋Ÿผ๋ช… = b.์ปฌ๋Ÿผ๋ช…; 

ํ…Œ์ด๋ธ”๋ช…์ด ๊ธด ๊ฒฝ์šฐ ํ…Œ์ด๋ธ”๋ช…์„ ๋‹ค ์จ์ฃผ์ง€์•Š๊ณ  ๋ณ„์นญ์„ ์“ธ ์ˆ˜ ์žˆ๋‹ค


โฆ ANSI ํ‘œ์ค€ ์กฐ์ธ (JOIN์ ˆ์„ ์ด์šฉํ•œ ๋ช…์‹œ์  ์กฐ์ธ)

JOIN์ ˆ์„ ๋ช…์‹œ์ ์œผ๋กœ ์„ ์–ธํ•˜์—ฌ ์งˆ์˜๋ฌธ์„ ์ž‘์„ฑํ•  ์ˆ˜๋„ ์žˆ๋‹ค.

SELECT ์ปฌ๋Ÿผ๋ช…1, ์ปฌ๋Ÿผ๋ช…2, ์ปฌ๋Ÿผ๋ช…3
  FROM ๋ฉ”์ธ ํ…Œ์ด๋ธ”๋ช… 		
     , ์กฐ์ธ ํ…Œ์ด๋ธ”๋ช… b	
 ON a.์ปฌ๋Ÿผ๋ช… = b.์ปฌ๋Ÿผ๋ช…;

โฆ ์งˆ์˜๋ฌธ ์‚ฌ์šฉํ•œ JOIN

JOIN์ ˆ์„ ๋ช…์‹œ์ ์œผ๋กœ ์„ ์–ธํ•˜์—ฌ ์งˆ์˜๋ฌธ์„ ์ž‘์„ฑํ•  ์ˆ˜๋„ ์žˆ๋‹ค.

SELECT ์ปฌ๋Ÿผ๋ช…1, ์ปฌ๋Ÿผ๋ช…2, ์ปฌ๋Ÿผ๋ช…3
  FROM ๋ฉ”์ธ ํ…Œ์ด๋ธ”๋ช… 		
     , ์กฐ์ธ ํ…Œ์ด๋ธ”๋ช… b	
 ON a.์ปฌ๋Ÿผ๋ช… = b.์ปฌ๋Ÿผ๋ช…;

post-custom-banner

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