Assuming I have 4 MySQL tables:
recipe: id, name
incredient: id, name
recipe_incredient: id, recipe_id, incredient_id
available: id, incredient_id
I want to have a query, which returns all recipes + incredient which there are incredients for.
Example:
I have Toast (= bread + ham) and Soup (= ham + chicken). I have bread and ham. Therefore I want to get Toast, but no Soup.
recipes:
1, Toast
2, Soup
incredients:
1, bread
2, ham
3, chicken
recipe_incredient:
1, 1, 1
2, 1, 2
3, 2, 2
3, 2, 3
available:
1, 1
2, 2
Result should be:
Toast, bread
Toast, ham