The operations team wants to view customer names alongside their orders.
The orders table contains order details, while the customers table stores customer information, including full_name.
Prepare a report showing each order and the name of the customer who placed it. Only orders belonging to customers found in the customers table should appear.
All order statuses are relevant, including orders with a missing status.
Ordering: Sort by order_id in ascending order.
Returnorder_idcustomer_idfull_name
About this problem
You practise joining two tables to add context to a list. The operations team wants each order from orders shown with the full_name of the customer who placed it, taken from customers, as order_id, customer_id and full_name, sorted by order_id. Only orders whose customer exists in customers belong in the report, and every status counts, including a missing one. The skill is picking the join type that matches that rule.
Reaching for LEFT JOIN out of habit is the main risk here. It keeps every order, so an order placed under a customer_id that has no row in customers comes back with an empty full_name, and the prompt excludes it. The sample has one such order, and it looks like a harmless gap in the report rather than a row that shouldn’t be there. The second risk is an unnecessary filter. Adding a status condition to tidy the output, such as leaving out cancelled orders, removes orders the prompt wants, and any <> test on status also drops the order with no status, because the comparison is unknown. Check your row count against orders: every order whose customer exists should appear once, whatever its status.
Read the lesson: Joins (P07) →