INSERT INTO customers (customer_name) VALUES('Alice'), ('Bob'), ('Charlie');INSERT INTO products (product_name, price) VALUES('Laptop', 1000.00),('Smartphone', 500.00),('Tablet', 300.00);INSERT INTO orders (customer_id, product_id, quantity) VALUES(1, 1, 2), (2, 2, 1), (3, NULL, 3);
1. INNER JOIN
Question: List all customers who placed orders with the product name and quantity.
SELECT c.customer_name, p.product_name, o.quantityFROM customers cINNER JOIN orders o ON c.customer_id = o.customer_idINNER JOIN products p ON o.product_id = p.product_id;
2. LEFT JOIN
Question: Show all customers and their orders, including orders without a product.
SELECT c.customer_name, p.product_name, o.quantityFROM customers cLEFT JOIN orders o ON c.customer_id = o.customer_idLEFT JOIN products p ON o.product_id = p.product_id;
3. FULL OUTER JOIN
Question: Show all customers, orders, and products, including those with no matches.
SELECT c.customer_name, o.order_id, p.product_nameFROM customers cFULL OUTER JOIN orders o ON c.customer_id = o.customer_idFULL OUTER JOIN products p ON o.product_id = p.product_id;