RIGHT JOIN


RIGHT JOIN is used to return all records from the right table and matching records from the left table.

If no matching record exists in the left table, NULL values are returned for left table columns.

RIGHT JOIN mainly focuses on the right table.

Even if related data is missing in the left table, all right table records are still displayed.

This join is useful in reporting systems.

Consider a scenario where all orders must be shown, even if customer information is missing.

RIGHT JOIN helps achieve this requirement.

The orders table may contain records that do not have matching customer entries.

RIGHT JOIN still displays those order records.

RIGHT JOIN query uses the RIGHT JOIN keyword.

The ON condition defines the table relationship.

All records from the right table are returned.

If an order has no matching customer, customer columns will show NULL values.

RIGHT JOIN is less commonly used than LEFT JOIN but is important to understand for interviews.