P a g e | 1
Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017
Assignment #2 – MySQL
Due: February 22, 2017 at 5:59 p.m.
Instructions:
Using the Northwind Database schema, write queries that will return the following data:
Upload a Word document (you may modify this one) to the assignment in Canvas
1. An alphabetical list of shippers and their phone numbers. 2. A list of the employees and their title that reside in London. 3. A list of products, their unit price, and units ordered by the customer B’s Beverages. 4. A list of all products, the supplier name, supplier contact, and phone of products no
longer in stock. 5. List the supplier name, phone, and category name for all dairy and meat/poultry
products that have been discontinued. 6. List all employees and their extension that have customers in Mexico, Brazil, or
Argentina. 7. List all orders that are shipped to regions in which Northwind has suppliers. 8. List all supplier regions that have orders shipped to them.
P a g e | 2
Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017
1.
SELECT CompanyName, Phone
FROM shippers
ORDER BY CompanyName ASC
LIMIT 0 , 30
2.
SELECT EmployeeID, FirstName, LastName, Title, TitleOfCourtesy
FROM employees
WHERE City = 'London'
LIMIT 0 , 30
P a g e | 3
Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017
3.
SELECT c.CompanyName, p.ProductID, p.ProductName, ord.UnitPrice, p.UnitsOnOrder, p.QuantityPerUnit, o.OrderDate
FROM products AS p, `order details` AS ord, customers AS c, orders AS o WHERE ( p.ProductID = ord.ProductID AND ord.OrderID = o.OrderID
AND o.CustomerID = c.CustomerID AND c.CompanyName = "B's Beverages"
)
LIMIT 0 , 30
P a g e | 4
Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017
4.
SELECT p.ProductID, p.ProductName, s.SupplierID, s.CompanyName, s.ContactNa
me, s.ContactTitle, s.Phone
FROM products AS p
INNER JOIN suppliers AS s ON ( p.SupplierID = s.SupplierID
AND p.discontinued = '1' )
LIMIT 0 , 30
P a g e | 5
Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017
5.
SELECT s.ContactName, s.ContactTitle, s.CompanyName, s.Phone, cat.CategoryNa
me, p.ProductID FROM suppliers AS s, categories AS cat, products AS p
WHERE (p.SupplierID = s.SupplierID) AND (p.CategoryID = cat.CategoryID) AND (cat.CategoryName = "Dairy Products"
OR cat.CategoryName = "Meat/Poultry") AND p.discontinued = '1'
LIMIT 0 , 30
6.
SELECT e.Title, e.TitleOfCourtesy, e.FirstName, e.LastName, e.Extension, o.EmployeeID, c.CustomerID, c.ContactName, c.Country
FROM employees AS e, orders AS o, customers AS c WHERE
(e.EmployeeID = o.EmployeeID) AND (o.CustomerID = c.CustomerID)
AND ( c.Country = "Mexico" OR c.Country = "Brazil" OR c.Country = "Argentina"
) LIMIT 0 , 30
P a g e | 6
Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017
7.
SELECT o.OrderID, ord.Quantity, p.ProductName, s.CompanyName, s.Region, s.Country FROM orders AS o, `order details` AS ord, products AS p, suppliers AS s
WHERE (o.OrderID = ord.OrderID) AND (ord.ProductID = p.ProductID)
AND (p.SupplierID = s.SupplierID) LIMIT 0 , 30
P a g e | 7
Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017
8.
SELECT p.SupplierID, s.City, s.Region, s.Country, o.OrderID, p.ProductName, ord.UnitPrice, p.QuantityPerUnit, o.OrderDate
FROM suppliers AS s, products AS p, `order details` AS ord, orders AS o WHERE
((s.supplierID = p.SupplierID) AND (p.ProductID = ord.ProductID) AND (ord.OrderID = o.OrderID))
LIMIT 2130 , 30
P a g e | 8
Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017
P a g e | 9
Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017