SQL Server Interview Question #64
What is a RIGHT JOIN?
Joins, Subqueries, CTEs & Set Operators Mid-Level Intermediate
Detailed Explanation
RIGHT JOIN, or RIGHT OUTER JOIN, returns every row from the right table and matching rows from the left table. Unmatched left-side columns become NULL.
Most RIGHT JOIN queries can be rewritten as LEFT JOIN by reversing table order. Many teams prefer LEFT JOIN for consistency and readability, but RIGHT JOIN is fully supported.
Code Example
SELECT p.Name AS ProductName,
c.Name AS CategoryName
FROM dbo.Products AS p
RIGHT JOIN dbo.Categories AS c
ON p.CategoryId = c.Id;