Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 935767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:12:32+00:00 2026-05-15T21:12:32+00:00

The recipe db continues… categories cid | category_name 1 | desserts 2 | cakes

  • 0

The recipe db continues…

categories

cid | category_name
 1  | desserts
 2  | cakes
 3  | biscuits

recipes

id | recipe_name
1  | black forest cake
2  | angel cake
3  | melting moments
4  | croquembouche
5  | crepes suzette

ingredients

iid | ingredient_code | ingredient_name      | ingredient_brand
 1  |     abc201      | self-raising flour   |    white wings
 2  |     abc202      | milk                 |    pura
 3  |     abc203      | chocolate            |    plaistock
 4  |     abc204      | baking powder        |    mackenzie
 5  |     abc205      | plain flour          |    white wings
 6  |     abc206      | eggs                 |    free range

recipe_categories

recipe_id | category_id
   1      |    1
   4      |    1
   5      |    1
   1      |    2
   2      |    2
   3      |    3
   4      |    3

recipe_ingredients

recipe_id | ingredient_id
   1      |    1
   2      |    1
   4      |    1
   1      |    2
   2      |    2
   3      |    2
   5      |    2
   1      |    3
   2      |    3
   1      |    4
   3      |    5
   4      |    5

As suggested by ozatomic, I’m using the following query:

SELECT A.recipe_name, GROUP_CONCAT(ingredient_name) AS ingredient_names
FROM recipes A
LEFT JOIN recipe_ingredients B ON A.id = B.recipe_id
LEFT JOIN ingredients C ON B.ingredient_id = C.iid
LEFT JOIN recipe_categories D ON A.id = D.recipe_id
LEFT JOIN categories E ON D.category_id = E.cid
WHERE category_id = <search_id>
GROUP BY id

Problem is, I’ve realised I’m going to need additional fields in the ingredients table, such as ingredient_code and ingredient_brand, which will mean that I’m unable to use GROUP_CONCAT to list ingredients as I need the following outputted to web (still by category):

black forest cake:
abc201  white wings   self-raising flour
abc202  pura          milk
abc203  plaistock     chocolate

croquembouche:
abc201  white wings   self-raising flour
abc204  white wings   plain flour

crepes suzette:
abc202  pura          milk
abc205  white wings   plain flour
abc206  free range    eggs 

I get the feeling that I’m either going to have to use two queries to achieve this, or use a foreach loop. Which would be best and how would I go about it?

edit: I also need to be able to format the results, using html tags or putting in divs or whatever.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T21:12:32+00:00Added an answer on May 15, 2026 at 9:12 pm

    The answer I gave when you asked this yesterday still applies. 🙂

    You are indeed going to have to put together a list and loop over it to pull out the exact data you’re looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

recipe_category cid | category 1 | desserts 2 | cakes 3 | biscuits recipe_name
I'm using a recipe from the iOS Recipes PragProg book, here's the original portion
Any time I use the recipe at http://code.activestate.com/recipes/134892/ I can't seem to get it
I have 3 tables with this structure: Recipe id | recipe_name Ingredients id |
I have a recipe tracker tool for World of Warcraft players here: http://www.wowgeeks.com/tracker.php?item=recipes .
I have a Recipe Table: CREATE TABLE IF NOT EXISTS `RECIPES` ( `recipes_id` int(11)
I am building a recipe app where a user can view recipes, list ingredients,
I have two entities: Recipe and Ingredient. Entites: public class Ingredient { public int
I have a recipe blog and there is an option to print just the
I have a capistrano recipe that is using a remote database in a Rails

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.