Left Join vs Right Join — SQL Technical Interview Questions & Answers

Left Join vs Right Join

Left Join vs Right Join

  • LEFT keeps the left table complete. RIGHT keeps the right table complete. Same power. Teams pick LEFT and put the important table first.
  • Example: all students + marks if any → students LEFT JOIN marks. All marks + student name if any → marks LEFT JOIN students (or students RIGHT JOIN marks).
  • Trap: saying they return the same rows without swapping tables.
  • On the example next to this theory: Left Join vs Right Join — jOIN combines rows using a match condition between tables.

Technical Interview Tip: LEFT vs RIGHT = which table is mandatory. Prefer LEFT.

Code Examples for Left Join vs Right Join

Left Join vs Right Join — sample query

CREATE TABLE customers (id INTEGER PRIMARY KEY, name TEXT);
CREATE TABLE orders (id INTEGER PRIMARY KEY, customer_id INTEGER, total INTEGER);
INSERT INTO customers VALUES (1, 'Asha'), (2, 'Ravi');
INSERT INTO orders VALUES (10, 1, 500), (11, 1, 200);
SELECT c.name, o.total
FROM customers c
JOIN orders o ON o.customer_id = c.id;

Left Join vs Right Join — jOIN combines rows using a match condition between tables.

How to Explain Left Join vs Right Join to an Interviewer

How do you rewrite RIGHT JOIN as LEFT?

Swap the two tables Keep the same ON