Stephanie Warner headshot
Stephanie Warner|March 24, 2020
image (17)
image (17)
    No Data

    LEFT JOIN (or LEFT OUTER JOIN) renders ALL records from the table on the left side (Table 1) and all matching records of the table on the right side (Table 2). In a LEFT JOIN, records that do not have corresponding data from the right table will show ‘NULL’ values from columns/fields selected from the right table.


    NOTE: LEFT JOIN is very similar to RIGHT JOIN. The difference has to do with the table positioning in relation to the query.  The ‘left’ table is always the table referred to in the FROM clause. The ‘right’ table is the table used after the JOIN clause and the matching column in each table is what binds the tables together.

    LEFT JOIN Syntax:

    SELECT Table_1.Column_1, Table_1.Column_2, Table_2.Column_1, Table_2.Column_N.... FROM Table_1 LEFT JOIN Table_2 ON Table_1.Matching_Column = Table_2.Matching_Column;

    LEFT JOIN Example:

    Table 1
    image1 (1)
    Table 2
    unnamed (3)
    unnamed (4)

    LEFT JOIN Query:

    unnamed (5)
    Result Set:
    image (19)

    Notice how the bottom 2 rows render ‘NULL’ results from the ‘Customers’ table on the bottom right of the result set. The result set outputs this way because of the positioning of the tables in the query using the LEFT JOIN. This will list ALL records from the ‘Address’ table, whether they have customer information tied to the address or not. For the two records/row that do not, the information from the ‘Customers’ table outputs ‘NULL’ values.

    This blog post is part of our SQL series:
    Stephanie Warner headshot
    Stephanie Warner

    Stephanie is a big time math nerd, avid snowboarder, and overall winter lover. She enjoys the torture of running and traveling to work Ragnar Relay races. From shredding the gnar to getting far too invested in murder/crime documentaries, you'll also find her petting all the doggos. She was an employee of PDQ.

    Related articles