여러분이 사용하고 계신 브라우저는 HTML5를 지원하지 않기 때문에 몇몇 요소가 제대로 보이도록 JScript를 사용하고 있습니다. 하지만 여러분의 브라우저 설정에서 스크립트 기능이 꺼져있으므로, 현재 페이지를 제대로 확인하시려면 스크립트 기능을 켜주셔야 합니다. SQL - INNER JOIN 키워드
SQL – INNER JOIN 키워드
2주전 작성
2주전 수정

INNER JOIN

INNER JOIN 키워드는 두 테이블에서 일치하는 값이 있는 레코드를 선택한다.

INNER JOIN

구문

SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;

데이터베이스 예시

주문 테이블

OrderID CustomerID EmployeeID OrderDate ShipperID
10308 2 7 1996-09-18 3
10309 37 3 1996-09-19 1
10310 77 8 1996-09-20 2

고객 테이블

CustomerID CustomerName ContactName Address City PostalCode Country
1

Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany
2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico
3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico
고객 정보가 포함된 모든 주문을 선택

⭐ INNER JOIN 키워드는 열 간에 일치하는 경우 두 테이블에서 모든 행을 선택한다. “주문” 테이블에 “고객”에 일치하는 항목이 없는 레코드가 있는 경우 이러한 주문은 표시되지 않는다.

SELECT Orders.OrderID, Customers.CustomerName
FROM Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;
기본 예시
OrderID CustomerName
10248 Wilman Kala
10249 Tradição Hipermercados
10250 Hanari Carnes
10251 Victuailles en stock
10252 Suprêmes délices
10253 Hanari Carnes
10254 Chop-suey Chinese
10255 Richter Supermarkt
10256 Wellington Importadora
10257 HILARIÓN-Abastos
10258 Ernst Handel
10259 Centro comercial Moctezuma
10260 Old World Delicatessen
10261 Que Delícia
10262 Rattlesnake Canyon Grocery
10263 Ernst Handel
10264 Folk och fä HB
10265 Blondel père et fils
10266 Wartian Herkku
10267 Frankenversand
10268 GROSELLA-Restaurante
10269 White Clover Markets
10270 Wartian Herkku
10271 Split Rail Beer & Ale
10272 Rattlesnake Canyon Grocery
10273 QUICK-Stop
10274 Vins et alcools Chevalier
10275 Magazzini Alimentari Riuniti
10276 Tortuga Restaurante
10277 Morgenstern Gesundkost
10278 Berglunds snabbköp
10279 Lehmanns Marktstand
10280 Berglunds snabbköp
10281 Romero y tomillo
10282 Romero y tomillo
10283 LILA-Supermercado
10284 Lehmanns Marktstand
10285 QUICK-Stop
10286 QUICK-Stop
10287 Ricardo Adocicados
10288 Reggiani Caseifici
10289 B’s Beverages
10290 Comércio Mineiro
10291 Que Delícia
10292 Tradição Hipermercados
10293 Tortuga Restaurante
10294 Rattlesnake Canyon Grocery
10295 Vins et alcools Chevalier
10296 LILA-Supermercado
10297 Blondel père et fils
10298 Hungry Owl All-Night Grocers
10299 Ricardo Adocicados
10300 Magazzini Alimentari Riuniti
10301 Die Wandernde Kuh
10302 Suprêmes délices
10303 Godos Cocina Típica
10304 Tortuga Restaurante
10305 Old World Delicatessen
10306 Romero y tomillo
10307 Lonesome Pine Restaurant
10308 Ana Trujillo Emparedados y helados
10309 Hungry Owl All-Night Grocers
10310 The Big Cheese
10311 Du monde entier
10312 Die Wandernde Kuh
10313 QUICK-Stop
10314 Rattlesnake Canyon Grocery
10315 Island Trading
10316 Rattlesnake Canyon Grocery
10317 Lonesome Pine Restaurant
10318 Island Trading
10319 Tortuga Restaurante
10320 Wartian Herkku
10321 Island Trading
10322 Pericles Comidas clásicas
10323 Königlich Essen
10324 Save-a-lot Markets
10325 Königlich Essen
10326 Bólido Comidas preparadas
10327 Folk och fä HB
10328 Furia Bacalhau e Frutos do Mar
10329 Split Rail Beer & Ale
10330 LILA-Supermercado
10331 Bon app’
10332 Mère Paillarde
10333 Wartian Herkku
10334 Victuailles en stock
10335 Hungry Owl All-Night Grocers
10336 Princesa Isabel Vinhoss
10337 Frankenversand
10338 Old World Delicatessen
10339 Mère Paillarde
10340 Bon app’
10341 Simons bistro
10342 Frankenversand
10343 Lehmanns Marktstand
10344 White Clover Markets
10345 QUICK-Stop
10346 Rattlesnake Canyon Grocery
10347 Familia Arquibaldo
10348 Die Wandernde Kuh
10349 Split Rail Beer & Ale
10350 La maison d’Asie
10351 Ernst Handel
10352 Furia Bacalhau e Frutos do Mar
10353 Piccolo und mehr
10354 Pericles Comidas clásicas
10355 Around the Horn
10356 Die Wandernde Kuh
10357 LILA-Supermercado
10358 La maison d’Asie
10359 Seven Seas Imports
10360 Blondel père et fils
10361 QUICK-Stop
10362 Bon app’
10363 Drachenblut Delikatessend
10364 Eastern Connection
10365 Antonio Moreno Taquería
10366 Galería del gastrónomo
10367 Vaffeljernet
10368 Ernst Handel
10369 Split Rail Beer & Ale
10370 Chop-suey Chinese
10371 La maison d’Asie
10372 Queen Cozinha
10373 Hungry Owl All-Night Grocers
10374 Wolski
10375 Hungry Coyote Import Store
10376 Mère Paillarde
10377 Seven Seas Imports
10378 Folk och fä HB
10379 Que Delícia
10380 Hungry Owl All-Night Grocers
10381 LILA-Supermercado
10382 Ernst Handel
10383 Around the Horn
10384 Berglunds snabbköp
10385 Split Rail Beer & Ale
10386 Familia Arquibaldo
10387 Santé Gourmet
10388 Seven Seas Imports
10389 Bottom-Dollar Marketse
10390 Ernst Handel
10391 Drachenblut Delikatessend
10392 Piccolo und mehr
10393 Save-a-lot Markets
10394 Hungry Coyote Import Store
10395 HILARIÓN-Abastos
10396 Frankenversand
10397 Princesa Isabel Vinhoss
10398 Save-a-lot Markets
10399 Vaffeljernet
10400 Eastern Connection
10401 Rattlesnake Canyon Grocery
10402 Ernst Handel
10403 Ernst Handel
10404 Magazzini Alimentari Riuniti
10405 LINO-Delicateses
10406 Queen Cozinha
10407 Ottilies Käseladen
10408 Folies gourmandes
10409 Océano Atlántico Ltda.
10410 Bottom-Dollar Marketse
10411 Bottom-Dollar Marketse
10412 Wartian Herkku
10413 La maison d’Asie
10414 Familia Arquibaldo
10415 Hungry Coyote Import Store
10416 Wartian Herkku
10417 Simons bistro
10418 QUICK-Stop
10419 Richter Supermarkt
10420 Wellington Importadora
10421 Que Delícia
10422 Franchi S.p.A.
10423 Gourmet Lanchonetes
10424 Mère Paillarde
10425 La maison d’Asie
10426 Galería del gastrónomo
10427 Piccolo und mehr
10428 Reggiani Caseifici
10429 Hungry Owl All-Night Grocers
10430 Ernst Handel
10431 Bottom-Dollar Marketse
10432 Split Rail Beer & Ale
10433 Princesa Isabel Vinhoss
10434 Folk och fä HB
10435 Consolidated Holdings
10436 Blondel père et fils
10437 Wartian Herkku
10438 Toms Spezialitäten
10439 Mère Paillarde
10440 Save-a-lot Markets
10441 Old World Delicatessen
10442 Ernst Handel
10443 Reggiani Caseifici
고객 및 발송인 정보가 포함된 모든 주문을 선택
SELECT Orders.OrderID, Customers.CustomerName, Shippers.ShipperName
FROM ((Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID)
INNER JOIN Shippers ON Orders.ShipperID = Shippers.ShipperID);
기본 예시
OrderID CustomerName ShipperName
10248 Wilman Kala Federal Shipping
10249 Tradição Hipermercados Speedy Express
10250 Hanari Carnes United Package
10251 Victuailles en stock Speedy Express
10252 Suprêmes délices United Package
10253 Hanari Carnes United Package
10254 Chop-suey Chinese United Package
10255 Richter Supermarkt Federal Shipping
10256 Wellington Importadora United Package
10257 HILARIÓN-Abastos Federal Shipping
10258 Ernst Handel Speedy Express
10259 Centro comercial Moctezuma Federal Shipping
10260 Old World Delicatessen Speedy Express
10261 Que Delícia United Package
10262 Rattlesnake Canyon Grocery Federal Shipping
10263 Ernst Handel Federal Shipping
10264 Folk och fä HB Federal Shipping
10265 Blondel père et fils Speedy Express
10266 Wartian Herkku Federal Shipping
10267 Frankenversand Speedy Express
10268 GROSELLA-Restaurante Federal Shipping
10269 White Clover Markets Speedy Express
10270 Wartian Herkku Speedy Express
10271 Split Rail Beer & Ale United Package
10272 Rattlesnake Canyon Grocery United Package
10273 QUICK-Stop Federal Shipping
10274 Vins et alcools Chevalier Speedy Express
10275 Magazzini Alimentari Riuniti Speedy Express
10276 Tortuga Restaurante Federal Shipping
10277 Morgenstern Gesundkost Federal Shipping
10278 Berglunds snabbköp United Package
10279 Lehmanns Marktstand United Package
10280 Berglunds snabbköp Speedy Express
10281 Romero y tomillo Speedy Express
10282 Romero y tomillo Speedy Express
10283 LILA-Supermercado Federal Shipping
10284 Lehmanns Marktstand Speedy Express
10285 QUICK-Stop United Package
10286 QUICK-Stop Federal Shipping
10287 Ricardo Adocicados Federal Shipping
10288 Reggiani Caseifici Speedy Express
10289 B’s Beverages Federal Shipping
10290 Comércio Mineiro Speedy Express
10291 Que Delícia United Package
10292 Tradição Hipermercados United Package
10293 Tortuga Restaurante Federal Shipping
10294 Rattlesnake Canyon Grocery United Package
10295 Vins et alcools Chevalier United Package
10296 LILA-Supermercado Speedy Express
10297 Blondel père et fils United Package
10298 Hungry Owl All-Night Grocers United Package
10299 Ricardo Adocicados United Package
10300 Magazzini Alimentari Riuniti United Package
10301 Die Wandernde Kuh United Package
10302 Suprêmes délices United Package
10303 Godos Cocina Típica United Package
10304 Tortuga Restaurante United Package
10305 Old World Delicatessen Federal Shipping
10306 Romero y tomillo Federal Shipping
10307 Lonesome Pine Restaurant United Package
10308 Ana Trujillo Emparedados y helados Federal Shipping
10309 Hungry Owl All-Night Grocers Speedy Express
10310 The Big Cheese United Package
10311 Du monde entier Federal Shipping
10312 Die Wandernde Kuh United Package
10313 QUICK-Stop United Package
10314 Rattlesnake Canyon Grocery United Package
10315 Island Trading United Package
10316 Rattlesnake Canyon Grocery Federal Shipping
10317 Lonesome Pine Restaurant Speedy Express
10318 Island Trading United Package
10319 Tortuga Restaurante Federal Shipping
10320 Wartian Herkku Federal Shipping
10321 Island Trading United Package
10322 Pericles Comidas clásicas Federal Shipping
10323 Königlich Essen Speedy Express
10324 Save-a-lot Markets Speedy Express
10325 Königlich Essen Federal Shipping
10326 Bólido Comidas preparadas United Package
10327 Folk och fä HB Speedy Express
10328 Furia Bacalhau e Frutos do Mar Federal Shipping
10329 Split Rail Beer & Ale United Package
10330 LILA-Supermercado Speedy Express
10331 Bon app’ Speedy Express
10332 Mère Paillarde United Package
10333 Wartian Herkku Federal Shipping
10334 Victuailles en stock United Package
10335 Hungry Owl All-Night Grocers United Package
10336 Princesa Isabel Vinhoss United Package
10337 Frankenversand Federal Shipping
10338 Old World Delicatessen Federal Shipping
10339 Mère Paillarde United Package
10340 Bon app’ Federal Shipping
10341 Simons bistro Federal Shipping
10342 Frankenversand United Package
10343 Lehmanns Marktstand Speedy Express
10344 White Clover Markets United Package
10345 QUICK-Stop United Package
10346 Rattlesnake Canyon Grocery Federal Shipping
10347 Familia Arquibaldo Federal Shipping
10348 Die Wandernde Kuh United Package
10349 Split Rail Beer & Ale Speedy Express
10350 La maison d’Asie United Package
10351 Ernst Handel Speedy Express
10352 Furia Bacalhau e Frutos do Mar Federal Shipping
10353 Piccolo und mehr Federal Shipping
10354 Pericles Comidas clásicas Federal Shipping
10355 Around the Horn Speedy Express
10356 Die Wandernde Kuh United Package
10357 LILA-Supermercado Federal Shipping
10358 La maison d’Asie Speedy Express
10359 Seven Seas Imports Federal Shipping
10360 Blondel père et fils Federal Shipping
10361 QUICK-Stop United Package
10362 Bon app’ Speedy Express
10363 Drachenblut Delikatessend Federal Shipping
10364 Eastern Connection Speedy Express
10365 Antonio Moreno Taquería United Package
10366 Galería del gastrónomo United Package
10367 Vaffeljernet Federal Shipping
10368 Ernst Handel United Package
10369 Split Rail Beer & Ale United Package
10370 Chop-suey Chinese United Package
10371 La maison d’Asie Speedy Express
10372 Queen Cozinha United Package
10373 Hungry Owl All-Night Grocers Federal Shipping
10374 Wolski Federal Shipping
10375 Hungry Coyote Import Store United Package
10376 Mère Paillarde United Package
10377 Seven Seas Imports Federal Shipping
10378 Folk och fä HB Federal Shipping
10379 Que Delícia Speedy Express
10380 Hungry Owl All-Night Grocers Federal Shipping
10381 LILA-Supermercado Federal Shipping
10382 Ernst Handel Speedy Express
10383 Around the Horn Federal Shipping
10384 Berglunds snabbköp Federal Shipping
10385 Split Rail Beer & Ale United Package
10386 Familia Arquibaldo Federal Shipping
10387 Santé Gourmet United Package
10388 Seven Seas Imports Speedy Express
10389 Bottom-Dollar Marketse United Package
10390 Ernst Handel Speedy Express
10391 Drachenblut Delikatessend Federal Shipping
10392 Piccolo und mehr Federal Shipping
10393 Save-a-lot Markets Federal Shipping
10394 Hungry Coyote Import Store Federal Shipping
10395 HILARIÓN-Abastos Speedy Express
10396 Frankenversand Federal Shipping
10397 Princesa Isabel Vinhoss Speedy Express
10398 Save-a-lot Markets Federal Shipping
10399 Vaffeljernet Federal Shipping
10400 Eastern Connection Federal Shipping
10401 Rattlesnake Canyon Grocery Speedy Express
10402 Ernst Handel United Package
10403 Ernst Handel Federal Shipping
10404 Magazzini Alimentari Riuniti Speedy Express
10405 LINO-Delicateses Speedy Express
10406 Queen Cozinha Speedy Express
10407 Ottilies Käseladen United Package
10408 Folies gourmandes Speedy Express
10409 Océano Atlántico Ltda. Speedy Express
10410 Bottom-Dollar Marketse Federal Shipping
10411 Bottom-Dollar Marketse Federal Shipping
10412 Wartian Herkku United Package
10413 La maison d’Asie United Package
10414 Familia Arquibaldo Federal Shipping
10415 Hungry Coyote Import Store Speedy Express
10416 Wartian Herkku Federal Shipping
10417 Simons bistro Federal Shipping
10418 QUICK-Stop Speedy Express
10419 Richter Supermarkt United Package
10420 Wellington Importadora Speedy Express
10421 Que Delícia Speedy Express
10422 Franchi S.p.A. Speedy Express
10423 Gourmet Lanchonetes Federal Shipping
10424 Mère Paillarde United Package
10425 La maison d’Asie United Package
10426 Galería del gastrónomo Speedy Express
10427 Piccolo und mehr United Package
10428 Reggiani Caseifici Speedy Express
10429 Hungry Owl All-Night Grocers United Package
10430 Ernst Handel Speedy Express
10431 Bottom-Dollar Marketse United Package
10432 Split Rail Beer & Ale United Package
10433 Princesa Isabel Vinhoss Federal Shipping
10434 Folk och fä HB United Package
10435 Consolidated Holdings United Package
10436 Blondel père et fils United Package
10437 Wartian Herkku Speedy Express
10438 Toms Spezialitäten United Package
10439 Mère Paillarde Federal Shipping
10440 Save-a-lot Markets United Package
10441 Old World Delicatessen United Package
10442 Ernst Handel United Package
10443 Reggiani Caseifici Speedy Express
참고
Mingg`s Diary
밍구
공부 목적 블로그