RIGHT JOIN
Definition
RIGHT JOIN is a SQL join that returns all rows from the right table and the matching rows from the left table. If no match exists, NULL values are returned for left table columns.
What Problem It Solves
It solves the need to preserve all records from the right table while combining related data from the left table, even if relationships are missing.
What Happens If Not Used
Without RIGHT JOIN, you may only get matching records (INNER JOIN behavior) and lose unmatched rows from the right table.
Easy Wording
It “keeps everything from right side, matches from left if available.”
Technical Example
All orders are shown, even if some don’t have customer details linked properly. Customer info appears only if available. SELECT customers.name, orders.order_id FROM customers RIGHT JOIN orders ON customers.id = orders.customer_id; Result: all orders shown, with NULL customer name if no match exists.