A data analyst joins a customers table with an orders table on customer_id. Some customers have never placed an order. The analyst needs a result that includes ALL customers, with NULL values for order columns where no matching order exists. Which join type is correct?
Answer & explanation
Correct answer: B
WHY B: LEFT JOIN preserves all rows from the left (customers) table and fills right-side (order) columns with NULL where no matching row exists, perfectly satisfying the requirement to include all customers. WHY NOT A: INNER JOIN excludes non-matching rows from both sides, dropping customers without orders. WHY NOT C: RIGHT JOIN preserves all rows from the right (orders) table; customers with no orders would be dropped. WHY NOT D: CROSS JOIN has no filtering condition and multiplies every row combination, producing incorrect results. WHY NOT E: FULL OUTER JOIN includes all customers but also all unmatched orders, introducing extra rows the analyst does not want.