Get startedGet started for free

LEFT join

An INNER JOIN shows you exact matches. What about when you want to compare all the values in one table with another, to see which rows match? That's when you can use a LEFT JOIN.

A LEFT JOIN will return ALL rows in the first table, and any matching rows in the right table. If there aren't any matches in the right table for a particular row, then a NULL is returned. This quickly lets you assess the gaps in your data, and how many you have.

This exercise is part of the course

Introduction to SQL Server

View Course

Exercise instructions

Complete the LEFT JOIN, returning all rows from the specified columns from invoiceline and any matches from invoice.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

SELECT 
  invoiceline_id,
  unit_price, 
  quantity,
  billing_state
  -- Specify the source table
FROM ___
  -- Complete the join to the invoice table
___ JOIN ___
___ invoiceline.invoice_id = invoice.invoice_id;
Edit and Run Code