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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:15:22+00:00 2026-05-26T02:15:22+00:00

I’m simplifying my actual case to get the point across quicker, just as a

  • 0

I’m simplifying my actual case to get the point across quicker, just as a heads up if this seems nonsensical.

I have a table called Candy_Central. Candy_Central has all of the ids for my candy, the price per pound as well and a couple other significant pieces of information that are the same across all Candy records. It also has a field called Candy_Type. Candy_Type’s value might be chocolate, hard, gummy, or liquid.

I have another set of tables that are used for the candy information, but their use is determined by candy type. For instance, if I want the rest of the information about my prime chocolate bar, I need to go to Chocolate_Standard to get the rest of the information. If I’m looking up gummy worms with sugar on the outside, I need to go to Gummy_Standard. The reason is that the fields for one set of information are completely different than the fields for the other.

I have one more layer of information, colors. I have Candy that’s blue, I have candy that’s black, and I have candy that’s both colors. The way I’m currently storing this information, I have a table with the fields Candy_Id and Color. To find all of the colors I’d normally just do a query on this table using the color_id field to find the candy I’m interested in. But SQL of course is about finding all of your results. So if I wanted to find all of the gummy info I’d want to do a join or union of some sort. I’m not extremely familiar with this type of query so I’m not sure how to get the result table that I want, which is basically going to be [sorry for the psuedo query] (items from Candy_Main as CM … items from Gummy as g … items from color as c … where cm.candy_id = g.candy_id and cm.candy_id = c.candy_id ). If the gummy’s didn’t have colors, I’d just want null. I’m fine with getting multiple lines back for each candy_id, but I’d want this as limited as possible just so that post processing (turning the multiple candy lines into one object in my application) took as little time as possible.

Tables:

Candy_Main
    candy_id (primary key, auto increment, not null, etc)
    candy_name (varchar)
    candy_inventor_id (a primary key from some other table, but this is needed for the where clause.
    candy_type (varchar)

Gummy_Standard
    gummy_id (primary, auto)
    candy_id (should match to candy_main)
    softness (varchar)
    outer_coating_type (varchar)
    animal_likeness (varchar)

Gummy_Colors
    gummy_color_id (primary, auto)
    gummy_id (int)
    candy_id (int)
    color (varchar(64))

Gummy_Ingredients
    gummy_ingredient_id (primary, auto)
    gummy_id (int)
    candy_id (int)
    ingredient (varchar(64))

Now, I want to do a query for all entries where candy_inventor_id = 5 AND candy_type =
'gummy'
. At the end of the query, I’d want candy_name, candy_type, softness, outer_coating_type, animal_likeness, colors, and ingredients.

Color & ingredients are the only objects that aren’t 1 to 1 in this query, so I’d like there to be only as many entries as there are colors and ingredients. Thanks for the help if this is possible. I have a feeling that it’d be easy enough to limit this for just colors or just ingredients, but that it’ll be too difficult to do it with both.

  • 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-26T02:15:23+00:00Added an answer on May 26, 2026 at 2:15 am

    try this

    SELECT c.candy_name, c.candy_type, s.softness, s.outer_coating_type, 
          s.animal_likeness, 
          GROUP_CONCAT(gc.color), 
          GROUP_CONCAT(gi.ingredient)
    FROM candy_main c
    LEFT JOIN gummy_standard s on s.candy_id=c.candy_id
    LEFT JOIN gummy_colors gc on gc.candy_id = c.candy_id
    LEFT JOIN gummy_ingredients gi cl on cl.candy_id = c.candy_id
    WHERE c.candy_inventor_id=5 AND c.candy_type='gummy'
    GROUP BY gc.color , gi.ingredient
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

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.