开发者

How do I make a shopping list from multiple recipes in an SQL database?

开发者 https://www.devze.com 2023-04-04 22:25 出处:网络
I\'m working on using a recipe database in SQLw, 开发者_Go百科like the one in this question (which has helped a lot already) Structuring a recipe database , to combine the ingredients of several user

I'm working on using a recipe database in SQLw, 开发者_Go百科like the one in this question (which has helped a lot already) Structuring a recipe database , to combine the ingredients of several user selected recipes to a shopping list.

Also, the items on this shopping list are to be divided in two categories (eg: "groceries" and "check pantry")

Example case:

  1. User can select 7 recipes to make a weekly mealplan in a form (almost got this part)
  2. The given output is a shopping list of all the ingredients marked as "groceries" and a "check stock" list of all the ingredients marked as "pantry".

Any help at all would be much appreciated!


I had just posted a full solution, but given the subject here looks like it may be homework, I'm just going to point you in the right direction. If this isn't homework, leave a comment and I'll put the full solution back.

Since you have multiple recipes, a normal selection based on joins would give you back multiple rows per ingredient. You want some way to roll up all of the rows for a given ingredient into a single row and show a total of the quantity that you need.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号