From a page - MyBarCabinet - I can select what raw materials I have available. These raw materials (only the ID's) is put into an array and stored in a cookie.
Now; my goal is to only get the drinks that do not require any more/other raw materials than what is stored in the cookie. In other words; If I've checked that I only have "16", "34" and "35" available: only the drinks that only require these raw materials should show up, and not those drinks that consists of these in addition to other raw materials..
I query drinks, and all that, from a MySQL database. This part is build up of three tables: drinks_recipes
, drink_recipes_ingredients
and raw_materials
.
The drink_recipes_ingredients
-table is used to "link" the drink recipes with the raw materials.
If I do:
SELECT
dr.id drink_id, dr.name drink_name,
rm.name ingredient_name
FROM drink_recipes_ingredients dri
JOIN drink_recipes dr ON dr.id = dri.fk_recipes_id
JOIN raw_materials rm ON rm.id = dri.fk_raw_materials_id
WHERE rm.id IN (16,34,35)
This does exactly what I don't want. I'm getting all drinks that contains at least one of the selected raw materials.
I did have a look at this post: How to return a row only if multiple clauses are met, but I couldn't figure out how to do something similar in my case. But the goal looks like to be the same.