bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/SQL/SQL Tutorial
SQL•SQL Tutorial

SQL LEFT JOIN

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind SQL LEFT JOIN?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___(s)
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The LEFT JOIN and LEFT OUTER JOIN keywords are equal - the OUTER keyword is optional.
If there is no match in the right table, the result for the columns from the right table will be NULL.
The LEFT JOIN returns all rows from the left table (table1), and only the matched rows from the right table (table2).

Sql Left Join

The LEFT JOIN returns all rows from the left table (table1), and only the matched rows from the right table (table2).

If there is no match in the right table, the result for the columns from the right table will be NULL.

The LEFT JOIN and LEFT OUTER JOIN keywords are equal - the OUTER keyword is optional.

LEFT JOIN Syntax

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

Note

The syntax combines two tables based on a related column , and the ON keyword is used to specify the matching condition.

Demo Database

Below is a selection from the "Customers" table:

CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
1Alfreds FutterkisteMaria AndersObere Str. 57Berlin12209Germany
2Ana Trujillo Emparedados y heladosAna TrujilloAvda. de la Constitución 2222México D.F.05021Mexico
3Antonio Moreno TaqueríaAntonio MorenoMataderos 2312México D.F.05023Mexico

And a selection from the "Orders" table:

OrderIDCustomerIDEmployeeIDOrderDateShipperID
10308271996-09-183
103093731996-09-191
103107781996-09-202

Here we see that the related column between the two tables above, is the "CustomerID" column.

Previous

SQL INNER JOIN

Next

SQL RIGHT JOIN