The clearest answer is two tiny tables and the rows each join returns. Draw these on the whiteboard.
Employee Department
id name dept_id id name
1 Asha 10 10 Sales
2 Ravi 20 20 IT
3 Meera NULL 30 HR
INNER JOIN: only matching rows
SELECT e.name, d.name AS dept
FROM Employee e
INNER JOIN Department d ON e.dept_id = d.id;
Asha Sales
Ravi IT
Meera has no department and HR has no employee, so both are left out.
LEFT JOIN: every row from the left table
SELECT e.name, d.name AS dept
FROM Employee e
LEFT JOIN Department d ON e.dept_id = d.id;
Asha Sales
Ravi IT
Meera NULL
All employees appear; the department columns are NULL where there is no match. RIGHT JOIN is the mirror image (every department, so HR appears with a NULL employee). Most teams just swap the table order and use LEFT JOIN.
FULL OUTER JOIN: every row from both
SELECT e.name, d.name AS dept
FROM Employee e
FULL OUTER JOIN Department d ON e.dept_id = d.id;
Asha Sales
Ravi IT
Meera NULL
NULL HR
MySQL has no FULL JOIN. Combine a LEFT JOIN and a RIGHT JOIN with UNION.
Finding rows with no match
-- Departments with no employees
SELECT d.name
FROM Department d
LEFT JOIN Employee e ON e.dept_id = d.id
WHERE e.id IS NULL;
A common trap
A condition on the right table in WHERE turns a LEFT JOIN back into an INNER JOIN, because NULL rows fail the condition. Put it in the ON clause if you want to keep unmatched rows: LEFT JOIN Orders o ON o.cust_id = c.id AND o.year = 2026.
Follow-ups
- What is a CROSS JOIN and a SELF JOIN?
- Write a query for employees who earn more than their manager.
- JOIN versus a subquery: which is faster?
This answer was written by Debugger’s Space as practice material. It is asked in most Indian IT services interviews (TCS, Infosys, Wipro, HCLTech, Tech Mahindra, LTIMindtree, Accenture, Cognizant, Capgemini, IBM). See each company’s hiring steps and practice questions on Debugger’s Space.