Help with SQL joins

So I have 2 tables in my database. One called ‘recipes’ with a few columns including the primary key, recipe name, a B/L/D enumerated column (to see whether its breakfast, lunch, or dinner), etc. The other table is called ‘ingredients’ and as you might guess it holds rows if ingredients, each with a foreign key that matches it with the right recipe using that recipes primary key.

Could someone help me write a query that would return all columns from the ‘recipes’ table while OMITTING rows where its ingredients’ name = ‘x’ (some filter that the user gives the DB)?

SELECT recipes.id , recipes.name , recipes.BLD FROM recipes LEFT OUTER JOIN ingredients ON ingredients.recipe_id = recipes.id AND ingredients.name = 'X' WHERE ingredients.recipe_id IS NULL

Sorry it took me forever to get back to you, but thank you very much. Worked like a charm!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.