This is not homework. I changed the names of the tables and fields for illustrative purposes only. I admit that I am completely new to MySQL. Please consider this in your answer.
The best way to illustrate the query function I need is as follows:
I have two tables.
One table has a ratio of 0..1 to 0..n to another table.
Just for simplicity sake. Suppose the two tables were Recipe and Ingredient.
One of the fields in the table "Ingredient" refers to the recipe table, but may be zero.
For example only: 
I want to know SQL for something like: How many recipes does Olives need in amount of "1" and "Mushrooms" in amount of "2"
Being completely new to Structured Query Language, I'm not even sure what to do with Google for this information.
Am I on the right track with the following ?:
SELECT COUNT(DISTINCT Recipe.ID) AS Answer FROM Recipe, Ingredient WHERE Ingredient.RecipeID=Recipe.ID AND Ingredient.Name='Olives' AND Ingredient.Amount=1 AND Ingredient.Name='Mushrooms' AND Ingredient.Amount=2
I understand that this is completely wrong, because the Name cannot be BOTH Olives and Mushrooms ... but I don’t know what to put instead, since I need to consider all recipes as both, but only all recipes with both.
How can I correctly write such a query for MySQL?
source share