SQL Joins
SQL Joins
SQL Joins
❮ Previous Next ❯
SQL JOIN
A JOIN clause is used to combine rows from two or more tables, based on a related column
between them.
10308 2 1996-09-18
10309 37 1996-09-19
10310 77 1996-09-20
https://www.w3schools.com/sql/sql_join.asp 1/8
24/4/2019 SQL Joins
Notice that the "CustomerID" column in the "Orders" table refers to the "CustomerID" in the
HTML CSS MORE
"Customers" table. The relationship between the two tables above is the "CustomerID"
column.
Then, we can create the following SQL statement (that contains an INNER JOIN), that selects
records that have matching values in both tables:
Example
Try it Yourself »
(INNER) JOIN: Returns records that have matching values in both tables
LEFT (OUTER) JOIN: Return all records from the left table, and the matched records
from the right table
RIGHT (OUTER) JOIN: Return all records from the right table, and the matched
records from the left table
FULL (OUTER) JOIN: Return all records when there is a match in either left or right
table
https://www.w3schools.com/sql/sql_join.asp 2/8
24/4/2019 SQL Joins
Exercise:
Insert the missing parts in the JOIN clause to join the two tables Orders and
Customers , using the CustomerID field in both tables as the relationship between
the two tables.
SELECT *
FROM Orders
LEFT JOIN Customers
= ;
Submit Answer »
❮ Previous Next ❯
https://www.w3schools.com/sql/sql_join.asp 3/8
24/4/2019 SQL Joins
Hoteles en
Bogotá
desde $7
Reserve ahora
Hoteles en Playa
del Carmen
desde $8
Reserve ahora
Hoteles en París
desde $24
Reserve ahora
COLOR PICKER
HOW TO
Tabs
Dropdowns
Accordions
Side Navigation
https://www.w3schools.com/sql/sql_join.asp 4/8
24/4/2019 SQL Joins
Top Navigation
HTML CSS MORE
Modal Boxes
Progress Bars
Parallax
Login Form
HTML Includes
Google Maps
Range Sliders
Tooltips
Slideshow
Filter List
Sort List
SHARE
CERTIFICATES
HTML
CSS
JavaScript
SQL
Python
PHP
jQuery
Bootstrap
XML
Read More »
https://www.w3schools.com/sql/sql_join.asp 5/8
24/4/2019 SQL Joins
Hoteles en Playa
del Carmen
desde $8
Reserve ahora
Hoteles en
Bogotá
desde $7
Reserve ahora
Hoteles en Miami
Beach
desde $15
Reserve ahora
https://www.w3schools.com/sql/sql_join.asp 6/8
24/4/2019 SQL Joins
PRINT PAGE
FORUM
ABOUT
Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
W3.CSS Tutorial
Bootstrap Tutorial
PHP 5 Tutorial
PHP 7 Tutorial
jQuery Tutorial
Java Tutorial
Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
W3.CSS Reference
Bootstrap Reference
PHP Reference
HTML Colors
jQuery Reference
Angular Reference
Java Reference
Top Examples
HTML Examples
CSS Examples
JavaScript Examples
How To Examples
SQL Examples
Python Examples
W3.CSS Examples
Bootstrap Examples
PHP Examples
jQuery Examples
https://www.w3schools.com/sql/sql_join.asp 7/8
24/4/2019 SQL Joins
Java Examples
HTML CSS MORE XML Examples
Web Certificates
HTML Certificate
CSS Certificate
JavaScript Certificate
SQL Certificate
Python Certificate
jQuery Certificate
PHP Certificate
Bootstrap Certificate
XML Certificate
Get Certified »
W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and
basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot
warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use,
cookie and privacy policy. Copyright 1999-2019 by Refsnes Data. All Rights Reserved.
Powered by W3.CSS.
https://www.w3schools.com/sql/sql_join.asp 8/8