Complete the code to select all customers and their orders, including customers with no orders.
SELECT customers.name, orders.order_id FROM customers [1] orders ON customers.id = orders.customer_id;The LEFT JOIN returns all rows from the left table (customers) and matching rows from the right table (orders). If there is no match, order columns will be NULL.
Complete the code to find customers with no orders using LEFT JOIN.
SELECT customers.name FROM customers LEFT JOIN orders ON customers.id = orders.customer_id WHERE orders.order_id [1];When using LEFT JOIN, customers without orders have orders.order_id as NULL. Filtering with IS NULL finds those customers.
Fix the error in the query to include all customers and their orders, showing NULL for missing orders.
SELECT c.name, o.order_id FROM customers c [1] orders o ON c.id = o.customer_id WHERE o.order_id > 100;
Using LEFT JOIN keeps all customers. But the WHERE clause filters out NULL orders, so to keep NULLs, the condition should be in the ON clause or use LEFT JOIN with care.
Fill both blanks to select all customers and their orders, showing NULL for missing orders, and order by customer name.
SELECT [1], [2] FROM customers LEFT JOIN orders ON customers.id = orders.customer_id ORDER BY customers.name;
Selecting customers.name and orders.order_id shows customer names and their orders. LEFT JOIN ensures all customers appear, even without orders (NULL order_id).
Fill all three blanks to create a query that lists all customers, their order IDs, and filters to show only customers with no orders.
SELECT [1], [2] FROM customers [3] orders ON customers.id = orders.customer_id WHERE orders.order_id IS NULL;
This query uses LEFT JOIN to include all customers, selects customer names and order IDs, and filters for customers with no orders by checking orders.order_id IS NULL.