Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Healthy Shop database
MULTIPLE JOINs – Exercises
12. Exercise 8

Instruction

Good job! One more and we're done!

Exercise

Show the name and price of each product in the 'fruits' and 'vegetables' departments. Consider only those products that are not produced by 'GoodFoods'.

Remember that if you place the condition for the producer's name in the WHERE clause, you won't get rows for products without a producer.

Stuck? Here's a hint!

To get also products that don't have a producer, you'll need to join the producer table, like so:

FROM product p
LEFT JOIN producer prod
  ON p.producer_id = prod.id
  AND prod.name != 'GoodFoods'
JOIN department d
  ON d.id = p.department_id
WHERE prod.id IS NOT NULL