➡️ 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)
| customer_id | name |
|---|---|
| 1 | Rahul |
| 2 | Anjali |
| 3 | Aman |
orders (Right Table)
| order_id | customer_id |
|---|---|
| 101 | 1 |
| 102 | 3 |
| 103 | 4 |
📄 RIGHT JOIN Example
SELECT c.name, o.order_id
FROM customers c
RIGHT JOIN orders o
ON c.customer_id = o.customer_id;
✅ Result
| name | order_id |
|---|---|
| Rahul | 101 |
| Aman | 102 |
| NULL | 103 |
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.