Complete the code to select all columns from the two tables joined on the customer ID.
SELECT * FROM customers [1] orders ON customers.customer_id = orders.customer_id;The JOIN keyword is used to combine rows from two or more tables based on a related column.
Complete the code to perform an inner join between products and sales on product_id.
SELECT products.name, sales.quantity FROM products [1] JOIN sales ON products.product_id = sales.product_id;An INNER JOIN returns only the rows where there is a match in both tables.
Fix the error in the join condition to correctly join employees and departments on department_id.
SELECT employees.name, departments.name FROM employees JOIN departments ON employees.[1] = departments.department_id;The join condition must use the exact column name department_id from employees to match departments.
Fill both blanks to write a query that joins orders and customers, selecting order_id and customer name, filtering only orders with amount greater than 100.
SELECT orders.order_id, customers.name FROM orders [1] JOIN customers ON orders.customer_id = customers.customer_id WHERE orders.amount [2] 100;
Use INNER JOIN to get matching rows and > to filter amounts greater than 100.
Fill all three blanks to write a query that joins three tables: sales, products, and categories. Select product name and category name for sales with quantity less than 50.
SELECT products.name, categories.name FROM sales [1] JOIN products ON sales.product_id = products.product_id [2] JOIN categories ON products.category_id = categories.category_id WHERE sales.quantity [3] 50;
Use INNER JOIN for both joins to get matching rows only, and < to filter quantity less than 50.