PHP MySQL recipe search based on what ingredients are provided -
Say I have a database of recipes, and I want to search based on the content I have.
There should be 3 tables:
Recipes (free, rname), content (iid, iname),
relationship (redemption, id)
Next, imagine that I have a recipe for 'toast' and there is a recipe for 'bread and butter pudding' - the toast has 2 ingredients (bread and butter) - in the pudding, bread and butter, plus flour, eggs and There can be water - then 5 overall.
My problem is, prepare a SQL query based on the content provided in a search. If I present 3 materials in my search - bread, butter and eggs - then (only discussed with 2 recipes) only one result should be produced - Toast! - Because there is not enough material to make pudding!
So what exactly does such SQL queries look like? I have tried everything, everything is gone and now my brain can not handle it anymore.
I do not know if this is the best way, but for example you did this job:
Select recipes from the selection, do not get rid of (/ * exclude all recipes with other ingredients * / relieve selection relationship My Sorry for English =)
Edit: Content 'IDs are in the order that they' in your question, then there is 1 bread, 2 butter, 4 eggs:
"Iid"; "Iname" "1"; "Bread" "2"; "Butter" "3"; "Dough" "4"; "Eggs" "5"; "Water"
Comments
Post a Comment