Ultimate access to all questions.
A data engineer needs to join two tables, customers
and orders
, on the condition c.customer_id = o.order_customer_id
. The goal is to retrieve details of all customers, including those who have not placed any orders, along with the details of orders they have placed. Given the schemas of both tables, which join operation should be used to achieve this?
Explanation:
The correct answer is to use either a LEFT OUTER JOIN
or a RIGHT OUTER JOIN
. This is because the requirement is to fetch all records from the customers
table (including those without orders) and only matching records from the orders
table. A LEFT OUTER JOIN
with customers
on the left and orders
on the right, or a RIGHT OUTER JOIN
with orders
on the left and customers
on the right, will both satisfy the requirement. This approach ensures that all customers are included in the results, regardless of whether they have placed any orders.