Categories: SQL Training
Tags:

In this tutorial you will learn SQL commands to Join 6 Tables together and then answer the data analysis questions.

Dataset Used in the project is Northwind Superstore SQL Database

3 Tables Join Code


SELECT products.ProductName, suppliers.CompanyName, categories.CategoryName, products.UnitPrice
FROM products
JOIN suppliers ON products.SupplierID = suppliers.SupplierID
JOIN categories ON products.CategoryID = categories.CategoryID;

4 – Tables Join

SELECT products.ProductName, suppliers.CompanyName, categories.CategoryName, products.UnitPrice, order_details.OrderID, order_details.Quantity
FROM products
JOIN suppliers ON products.SupplierID = suppliers.SupplierID
JOIN categories ON products.CategoryID = categories.CategoryID
JOIN order_details ON products.ProductID = order_details.ProductID

5 – Tables Join Code

SELECT products.ProductName, suppliers.CompanyName, categories.CategoryName, products.UnitPrice, order_details.OrderID, order_details.Quantity, orders.CustomerID, orders.RequiredDate
FROM products
JOIN suppliers ON products.SupplierID = suppliers.SupplierID
JOIN categories ON products.CategoryID = categories.CategoryID
JOIN order_details ON products.ProductID = order_details.ProductID
JOIN orders ON order_details.OrderID = orders.OrderID
ORDER BY orders.RequiredDate

6 – Tables Join Code Example


SELECT products.ProductName, suppliers.CompanyName, categories.CategoryName, products.UnitPrice, order_details.OrderID, order_details.Quantity, orders.CustomerID, orders.RequiredDate, customers.ContactName, customers.City
FROM products
JOIN suppliers ON products.SupplierID = suppliers.SupplierID
JOIN categories ON products.CategoryID = categories.CategoryID
JOIN order_details ON products.ProductID = order_details.ProductID
JOIN orders ON order_details.OrderID = orders.OrderID
JOIN customers ON orders.CustomerID = customers.CustomerID
ORDER BY orders.RequiredDate;