
Originally Posted by
groody_son
So, here are the tables:
table3: recipes_ingredients
recipe_ingredient_code|recipe_code|ingredient_code|ingredient_quantity
i prefer without the recipe_ingredient_code column
and the query is like this --
Code:
SELECT r.recipe_code
FROM recipes AS r
INNER
JOIN recipes_ingredients AS ri
ON ri.recipe_code = r.recipe_code
INNER
JOIN ingredients AS i
ON i.ingredient_code = ri.ingredient_code
WHERE ( i.ingredient_name='salt' AND ri.ingredient_quantity BETWEEN 1 AND 2 )
OR ( i.ingredient_name='rice' AND ri.ingredient_quantity BETWEEN 100 AND 200 )
GROUP
BY r.recipe_code
HAVING COUNT(*) = 2
Bookmarks