Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tutorial 5 Multi-table queries. Tutorial 5 objectives Displaying Data from Multiple Tables –[ ]Write SELECT statements to access data from more than one.

Similar presentations


Presentation on theme: "Tutorial 5 Multi-table queries. Tutorial 5 objectives Displaying Data from Multiple Tables –[ ]Write SELECT statements to access data from more than one."— Presentation transcript:

1 Tutorial 5 Multi-table queries

2 Tutorial 5 objectives Displaying Data from Multiple Tables –[ ]Write SELECT statements to access data from more than one table using equality and non-equality joins

3 Using Northwind… 1.Show the product Id, the product name, the category id and the category name. 2.Show the customerID, company name and OrderId of all customers who have orders. 3.Show the customer’s CompanyName and the first and last name of any employee who has filled an order for that customer. 4.Repeat 3 using the ‘distinct’ keyword straight after the word select. Note the difference in the number of rows. 5.Show the companyname and the name of each product the customer has ordered. 6.Repeat 5, ordering the result by companyname and productname. 7.Repeat 6, using the ‘distinct’ keyword.

4 Northwind data model

5 Testing the joins select customers.customerId, CompanyName, orderId from customers left join orders on customers.customerID=orders.customerID where orders.customerID is null


Download ppt "Tutorial 5 Multi-table queries. Tutorial 5 objectives Displaying Data from Multiple Tables –[ ]Write SELECT statements to access data from more than one."

Similar presentations


Ads by Google