PDQ.com mobilePDQ.com desktop
Support

SQL LEFT JOIN

Stephanie WarnerStephanie Warner
·

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
Table 2

LEFT JOIN Query:

Result Set:

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:

SQL UNION vs UNION ALL

SQL JOINS

SQL INNER JOIN

SQL Set Operators

SQL Right Join

SQL Full Outer Join

Ready to get started with PDQ Deploy & Inventory?

Take our 14-day Free Trial.
This round is on us!

Don't miss the next post!

August 2020 Patch Tuesday Vulnerabilities

August 2020 Patch Tuesday Updates and Vulnerabilities

PDQ.com
© 2020 PDQ.com Corporation

Products

  • Deploy
  • Inventory
  • Enterprise SL
  • Pricing
  • Downloads
  • Licensing
  • Buy