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 product_name, product_price, department_name, and producer_name, respectively.

Stuck? Here's a hint!

Type:

SELECT
  p.name AS product_name,
  p.price AS product_price,
  prod.name producer_name,
  d.name department_name
FROM product p
JOIN producer prod
  ON p.producer_id = prod.id
JOIN department d
  ON d.id = p.department_id