Skip to main content

What does RIGHT JOIN do?

RIGHT JOIN does the same as LEFT JOIN, only the other way around - it returns all rows from the right table and only the matching rows from the left one.

If the left table has no match, NULL fills its place.

Example

sql
SELECT * FROM orders RIGHT JOIN customers ON orders.customer_id = customers.id;

Result: every customer ends up in it, even those without orders, but the orders data for those customers comes back as NULL.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.