Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Healthy Shop database
MULTIPLE JOINs – Exercises
7. Exercise 3 – Get to know the Producer table

Instruction

Great! We can't have products without producers, can we? Time for another table!

Exercise

The Producer table consists of two columns, similar to the Department table:

  • Id – the ID of a given food producer, and
  • Name – the name of the producer.

Okay! Let's make use of our new table straight away. For each product show its name, price, department name, and producer name.

Alias the columns as ProductName, ProductPrice, DepartmentName, and ProducerName, respectively.

Stuck? Here's a hint!

Type:

SELECT
  P.Name AS ProductName,
  P.Price AS ProductPrice,
  Prod.Name ProducerName,
  D.Name DepartmentName
FROM Product P
JOIN Producer Prod
  ON P.ProducerId = Prod.Id
JOIN Department D
  ON D.Id = P.DepartmentId