Interview Question

Difference between INNER JOIN and OUTER JOIN?

Inner joins keep matches; outer joins can also keep unmatched rows.

💡 Concept ✅ Quick Revision 🗃️ SQL

Answer

An inner join returns only matching combinations, while an outer join also preserves selected unmatched rows. • LEFT preserves unmatched left rows. • RIGHT preserves unmatched right rows, and FULL preserves both sides. • Outer-join filters must be placed carefully to avoid removing preserved rows.

💡 SQL Example

SELECT c.name, o.order_id FROM customers c LEFT JOIN orders o ON o.customer_id = c.customer_id;

Result

Customers with and without orders

⚡ Quick Revision

Inner joins keep matches; outer joins can also keep unmatched rows.