Complete the code to select all customers and their orders, even if they have no orders.
SELECT customers.name, orders.order_id FROM customers [1] orders ON customers.id = orders.customer_id;LEFT JOIN returns all rows from the left table (customers) and matching rows from the right table (orders). If no match, NULLs appear.
Complete the code to select all orders and their customers, even if some orders have no customer info.
SELECT orders.order_id, customers.name FROM orders [1] customers ON orders.customer_id = customers.id;LEFT JOIN returns all rows from the left table (orders) and matching rows from the right table (customers). If no match, NULLs appear.
Fix the error in the join to get all employees and their departments, even if some employees have no department.
SELECT employees.name, departments.name FROM employees [1] departments ON employees.dept_id = departments.id;LEFT JOIN keeps all employees even if they don't belong to a department. INNER JOIN excludes employees without departments.
Fill both blanks to select all products and their suppliers, even if some products have no supplier info.
SELECT products.name, suppliers.name FROM products [1] suppliers ON products.supplier_id [2] suppliers.id;
LEFT JOIN keeps all products. The ON condition uses '=' to match supplier IDs.
Fill all three blanks to select all orders and their shipping info, even if some orders have no shipping data.
SELECT orders.id, shipping.status, shipping.date FROM orders [1] shipping ON orders.ship_id [2] shipping.id AND shipping.status [3] 'delivered';
LEFT JOIN keeps all orders. ON uses '=' to match ship_id and != to only include non-delivered shipping, with NULLs otherwise.