RIGHT JOIN — Complete Guide
RIGHT 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 23 of 100
RIGHT JOIN
SQL basics → Queries → Advanced
SQL basics · 1 — SELECT · ~6 min · SQL — Joins & Relationships
What is this?
RIGHT JOIN keeps every row from the right table; left columns are NULL when unmatched. Most teams write LEFT JOIN by swapping table order instead.
Why should you care?
Same idea as LEFT JOIN — useful when the “must keep” table is already written on the right in a legacy query.
See it live — copy this example
Run in SQL Server Management Studio (SSMS) or Azure Data Studio.
USE DataVerse;
SELECT o.OrderId, o.Amount, c.FullName
FROM dbo.Customers AS c
RIGHT JOIN dbo.Orders AS o ON o.CustomerId = c.CustomerId;
What happened?
- All orders appear.
- If CustomerId is missing or invalid, FullName is NULL.
- Equivalent LEFT JOIN would put Orders on the left.
Practice next
- Run the RIGHT JOIN.
- Rewrite as FROM Orders o LEFT JOIN Customers c and compare results.
- Prefer the LEFT form in new your database code for readability.
- RIGHT JOIN Products from a sparse inventory table.
- Convert the query to LEFT JOIN and save that version.
Remember
RIGHT keeps all right rows. Usually rewrite as LEFT with swapped tables. NULL left columns mean no match.
Legacy report kept Orders on the right
An old DataVerse report used RIGHT JOIN; team rewrote it as LEFT.
Outcome: Same results, clearer code review.
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!