SQL LEFT JOIN

  • LEFT JOIN performs a join starting with the first (left-most) table and then any matching second (right-most) table records.
  • LEFT JOIN and LEFT OUTER JOIN are the same.
The definitive guide
for data professionals


Order today!
 See 2 min video



The SQL LEFT JOIN syntax


The general syntax is:
SELECT column-names
  FROM table-name1 LEFT JOIN table-name2 
    ON column-name1 = column-name2
 WHERE condition

The general LEFT OUTER JOIN syntax is:
SELECT OrderNumber, TotalAmount, FirstName, LastName, City, Country
  FROM Customer C LEFT JOIN [Order] O
    ON O.CustomerId = C.Id
ORDER BY TotalAmount
This will list all customers, whether they placed any order or not.
The ORDER BY TotalAmount shows the customers without orders first (i.e. TotalMount is NULL).

Results: 832 records

OrderNumber TotalAmount FirstName LastName City Country
NULL NULL Diego Roel Madrid Spain
NULL NULL Marie Bertrand Paris France
542912 12.50 Patricio Simpson Buenos Aires Argentina
542937 18.40 Paolo Accorti Torino Italy
542897 28.00 Pascale Cartrain Charleroi Belgium
542716 28.00 Maurizio Moroni Reggio Emilia Italy
543028 30.00 Yvonne Moncada Buenos Aires Argentina
543013 36.00 Fran Wilson Portland USA