I have three Table. The first Table contains a Rezipe with a id, the second Table contains the rezeptid with the ingredients and the third Table shows the ingredient with a restriction(vegan, meat…).
Im looking for a way to select a recipe if the ingredients dont contain a specific restriction and if it contains the restriction then return Null.
I first joined the three tables together and wrote the restriction in the where clausel, but i dont wanna return the recipe, if it contains a specific value
SELECT *
FROM `rezepte`
JOIN rezeptezutaten ON rezepte.REZEPTEID = rezeptezutaten.REZEPTEID
JOIN inhaltsstoffe ON inhaltsstoffe.ZUTATENNR = rezeptezutaten.ZUTATENNR
WHERE inhaltsstoffe.INHALTSSTOFFEID != 1;
2
Answers
You should be able to get all recipes that contain the ingredient with a particular restriction
you can then use this as a subquery
case when
null
and
statement during the joinsomething like