Skip to content
Advertisement

Only show Warehous where product is not existing – multiply tables mysql

I’ve got three tables. Product, Warehouse and IsIn.

Product:

  • productID
  • name
  • price

Warehouse:

  • warehousID
  • name

IsIn:

  • productID*
  • warehousID*
  • quantity

I now want to write a question where i get all warehouses where a specific product does not exist.

I can get a table where the specific product are, but when i try to get where it’s not, I get the wrong answer.

Does anyone know how i can write the question?

Advertisement

Answer

I now want to write a question where i get all warehouses where a specific product does not exist.

This sounds like a NOT EXISTS query:

You may want to add and i.quantity > 0 in the subquery. It is not clear if quantity is important for the question.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement