LEFT JOIN — Complete Guide
LEFT JOIN — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of SQL Server Tutorial on Toolliyo Academy.
On this page
SQL Server Tutorial · Lesson 22 of 100
LEFT JOIN
SQL basics → Queries → Advanced
SQL basics · 1 — SELECT · ~6 min · SQL — Joins & Relationships
What is this?
LEFT JOIN keeps every row from the left table. When the right side has no match, right columns are NULL.
Why should you care?
You want all customers, even those who never ordered — INNER JOIN would hide them.
See it live — copy this example
Run in SQL Server Management Studio (SSMS) or Azure Data Studio.
USE DataVerse;
SELECT c.CustomerId, c.FullName, o.OrderId, o.Amount
FROM dbo.Customers AS c
LEFT JOIN dbo.Orders AS o ON o.CustomerId = c.CustomerId
ORDER BY c.CustomerId;
What happened?
- Every customer appears at least once.
- Customers without orders show NULL OrderId/Amount.
- That pattern finds inactive shoppers.
Practice next
- Insert a customer with no orders.
- Run the LEFT JOIN and find the NULL order columns.
- Rewrite as INNER JOIN and confirm that customer vanishes.
- Move o.Amount > 1000 into the ON clause and compare to WHERE.
- LEFT JOIN a Cities table for address enrichment.
Remember
LEFT keeps all left rows. Missing right matches become NULL. Filter right columns carefully (ON vs WHERE).
Customers with zero orders
Marketing finds DataVerse customers WHERE OrderId IS NULL after LEFT JOIN.
Outcome: Win-back campaign targets true non-buyers.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!