Complete the code to join two tables on the common column.
SELECT * FROM orders JOIN customers ON orders.customer_id [1] customers.id;The JOIN condition must use '=' to match rows where the customer IDs are equal.
Complete the code to select only orders with matching customers using INNER JOIN.
SELECT orders.id, customers.name FROM orders [1] JOIN customers ON orders.customer_id = customers.id;INNER JOIN returns only rows with matching keys in both tables.
Fix the error in the JOIN condition to improve performance by using indexed columns.
SELECT * FROM products JOIN categories ON products.[1] = categories.id;Joining on the foreign key 'category_id' which is indexed improves performance.
Fill both blanks to write a query that uses an index-friendly JOIN and filters results efficiently.
SELECT o.id, c.name FROM orders o [1] JOIN customers c ON o.customer_id [2] c.id WHERE c.status = 'active';
INNER JOIN with '=' on indexed keys returns matching active customers efficiently.
Fill all three blanks to write a query that joins three tables efficiently with proper conditions.
SELECT p.name, c.name, s.quantity FROM products p [1] JOIN categories c ON p.category_id [2] c.id [3] stock s ON p.id = s.product_id WHERE s.quantity > 0;
Use INNER JOINs with '=' conditions to join tables on indexed keys and filter stock with quantity > 0.