Mysql – Help with SQL query

MySQL

I have 4 tables defined as follow :

Product(IdProduct,NameProduct,Color,Mass)
Supplier(IdSupplier,NameSupplier,CitySup)
Factory(IdFactory,NameFactory,CityFac)
Shipping(IdProduct,IdFactory,IdSupplier,Quantity) : the product Idproduct is shipped to the factory IdFactory by the Supplier IdSupplier with quantity Quantity

I need to get the list of IdProduct of products that are shipped to every factory in Paris (Factory.cityFac="Paris").
What is a proper approach to get this result in SQL ?

Best Answer

Notice that according to your question, Supplier is not needed to get the final result.

select p.IdProduct, p.NameProduct, p.Color, p.Mass
from Shipping s
     inner join Factory f
         on f.IdFactory = s.IdFactory
     inner join Product p
         on s.IdProduct = p.IdProduct
where
    f.CityFact = 'Paris';