What is a JOIN in SQL?
Why Interviewers Ask This
This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex MySQL / SQL topics. It also reveals how well you can explain technical ideas to non-experts.
Answer
A JOIN combines rows from two or more tables based on a related column. Types: INNER JOIN — returns only rows where the join condition matches in BOTH tables. Rows without a match are excluded. SELECT u.name, o.total FROM users u INNER JOIN orders o ON u.id = o.user_id; — only users who have orders, only orders with a valid user. LEFT JOIN (LEFT OUTER JOIN) — returns ALL rows from the left table plus matching rows from the right. If no match, right table columns are NULL. SELECT u.name, o.total FROM users u LEFT JOIN orders o ON u.id = o.user_id; — all users, including those with no orders (their order columns show NULL). RIGHT JOIN — mirror of LEFT JOIN (all rows from right table). FULL OUTER JOIN — all rows from both tables (MySQL doesn't support this natively — simulate with UNION of LEFT and RIGHT JOIN). CROSS JOIN — Cartesian product — every row from table A paired with every row from table B (n×m rows). SELF JOIN — joining a table with itself using aliases.
Pro Tip
Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a MySQL / SQL codebase.