Complete the code to select all customers who have no orders.
SELECT customers.id, customers.name FROM customers LEFT JOIN orders ON customers.id = orders.customer_id WHERE orders.customer_id IS [1];When using LEFT JOIN, unmatched rows in the right table have NULL values. So, to find customers without orders, we check where orders.customer_id IS NULL.
Complete the code to find products that have never been ordered.
SELECT products.id, products.name FROM products LEFT JOIN order_items ON products.id = order_items.product_id WHERE order_items.product_id IS [1];Products with no matching order_items will have NULL in order_items.product_id after the LEFT JOIN.
Complete the code to find employees without assigned projects.
SELECT e.id, e.name FROM employees e LEFT JOIN projects p ON e.id = p.employee_id WHERE p.employee_id IS [1];Employees with no matching projects will have NULL in p.employee_id after the LEFT JOIN. Use IS NULL to find them.
Fill both blanks to find customers without orders and select their id and name.
SELECT customers.[1], customers.[2] FROM customers LEFT JOIN orders ON customers.id = orders.customer_id WHERE orders.customer_id IS NULL;
We select the customer's id and name columns to identify customers without orders.
Fill all three blanks to find products without orders and select their id, name, and price.
SELECT [1], [2], [3] FROM products LEFT JOIN order_items ON products.id = order_items.product_id WHERE order_items.product_id IS NULL;
We select the product's id, name, and price to identify products without any orders.