➡️ RIGHT JOIN in SQL
Last Updated: January 2026
The RIGHT JOIN returns all rows from the right table and matching rows from the left table.
- If there is no match, columns from the left table become NULL.
- Right table → always preserved
- Left table → included only if matched
Hinglish Tip 🗣: Right table ka poora data chahiye, match ho ya na ho → RIGHT JOIN.
🧾 Basic Syntax
SELECT columns
FROM table1
RIGHT JOIN table2
ON table1.common_column = table2.common_column;
📄 Example Tables
customers (Left Table)
orders (Right Table)
📄 RIGHT JOIN Example
SELECT c.name, o.order_id
FROM customers c
RIGHT JOIN orders o
ON c.customer_id = o.customer_id;
Result
Explanation:
- Order 101 → matched → shown
- Order 102 → matched → shown
- Order 103 → no customer → customer fields NULL
🔁 RIGHT JOIN = LEFT JOIN (Table Swap)
This query:
A RIGHT JOIN B
Is logically the same as:
B LEFT JOIN A
👉 That's why RIGHT JOIN is rarely used in practice.
