SQL
Retrieve Data from Multiple Tables Using INNER JOIN
Master fetching related data from different tables by combining rows based on a common column with INNER JOIN, essential for relational databases.
SELECT
p.product_name,
p.price,
c.category_name,
m.manufacturer_name
FROM
products p
INNER JOIN
categories c ON p.category_id = c.category_id
INNER JOIN
manufacturers m ON p.manufacturer_id = m.manufacturer_id
WHERE
p.price > 100.00
ORDER BY
p.product_name;
How it works: This query shows how to combine information from three separate tables (`products`, `categories`, `manufacturers`) using `INNER JOIN`. It links rows where the `category_id` and `manufacturer_id` match across tables, retrieving product details along with their corresponding category and manufacturer names, filtered by products with a price greater than 100.00. The results are ordered by product name.