SQL - Join

๊น€ํ•œ์ค€ยท2021๋…„ 11์›” 2์ผ
0

๐Ÿš€ Join

  • ๊ณตํ†ต๋œ column์„ ๊ธฐ์ค€์œผ๋กœ ์—ฌ๋Ÿฌ ํ…Œ์ด๋ธ”์„ ํ•ฉ์นœ๋‹ค.

๐Ÿš€ Inner Join

  • ๊ต์ง‘ํ•ฉ
SELECT * FROM ๊ธฐ์ค€ํ…Œ์ด๋ธ”
INNER JOIN ๋ถ™์ผํ…Œ์ด๋ธ” ON join_๊ธฐ์ค€์—ด

๐Ÿš€ Left Join

  • ์™ผ์ชฝ ๋ฐ์ดํ„ฐ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋ถ™์ด๊ธฐ
SELECT * FROM ๊ธฐ์ค€ํ…Œ์ด๋ธ”
LEFT JOIN ๋ถ™์ผํ…Œ์ด๋ธ” ON join_๊ธฐ์ค€์—ด

๐Ÿš€ Right Join

  • ์˜ค๋ฅธ์ชฝ ๋ฐ์ดํ„ฐ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋ถ™์ด๊ธฐ
SELECT * FROM ๊ธฐ์ค€ํ…Œ์ด๋ธ”
RIGHT JOIN ๋ถ™์ผํ…Œ์ด๋ธ” ON join_๊ธฐ์ค€์—ด

๐Ÿš€ Outer Join

  • ๋ฐ์ดํ„ฐ๊ฐ€ ์—†๋Š” ๋ถ€๋ถ„์€ null๋กœ ๊ฐ€์ ธ์˜จ๋‹ค.
  • FULL OUTER JOIN : ์ „์ฒด ํ•ฉ์น˜๊ธฐ
  • LEFT OUTER JOIN = LEFT JOIN
  • RIGHT OUTER JOIN = RIGHT JOIN
SELECT * FROM ๊ธฐ์ค€ํ…Œ์ด๋ธ”
OUTER JOIN ๋ถ™์ผํ…Œ์ด๋ธ” ON join_๊ธฐ์ค€์—ด

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