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 949793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:27:36+00:00 2026-05-15T23:27:36+00:00

Following on from my query yesterday , I’ve restructured my recipe database as follows:

  • 0

Following on from my query yesterday, I’ve restructured my recipe database as follows:

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_name
 1  | self-raising flour
 2  | milk
 3  | chocolate
 4  | baking powder
 5  | plain flour
 6  | eggs

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

My query needs to return recipes by category with ingredients listed using
to separate the ingredients (possibly using GROUP_CONCAT(i.ingredient_name separator ‘
‘) output as suggested yesterday).

So, a query for desserts would output:

black forest cake:
self-raising flour
milk
chocolate

croquembouche:
self-raising flour
plain flour

crepes suzette:
milk
plain flour

I know I have to join recipe_ingredients and recipes and ingredients and search categories, but I’m really struggling on how to do this.

  • 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-15T23:27:37+00:00Added an answer on May 15, 2026 at 11:27 pm

    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 = <serach_id>
    GROUP BY id
    

    Result:

    +-------------------+-------------------------------------------------+
    | recipe_name       | ingredient_names                                |
    +-------------------+-------------------------------------------------+
    | black forest cake | chocolate,baking powder,self-raising flour,milk |
    | angel cake        | self-raising flour,milk,chocolate               |
    | melting moments   | milk,plain flour                                |
    | croquembouche     | self-raising flour,plain flour                  |
    | crepes suzette    | milk                                            |
    +-------------------+-------------------------------------------------+
    

    Here is what you asked for using the GROUP_CONCAT. Each ingredient is seperated by ,

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

Sidebar

Related Questions

i have the following query from msdn to restore a SQL Server database backup
I'm trying to run the following query from phpMyAdmin (on a local WAMP server):
Why Nibernate HQL can not handle the following query: from Deal D where (D.ApprovalDate
I have table that I insert data with following query (from c# code): INSERT
I have the following LINQ query: From metasect In DirectCast(Form.ChildDocBox.Tag, META_DOCUMENT).META_SECTIONS From metaset In
Take the following query: select * from ( select a, b from c UNION
Given a query like the following: DELETE FROM FOO WHERE ID in (1,2,3,4,....); Is
I have the following query: SELECT * FROM table_name WHERE (col_1 LIKE '%$keyword%' OR
I have the following query: SELECT * FROM ( `teams` ) WHERE `name` =
I have the following XML LINQ query from my XDocument. var totals = (from

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.