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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:09:14+00:00 2026-05-30T13:09:14+00:00

Not too sure if the title to this actually explains what I really need

  • 0

Not too sure if the title to this actually explains what I really need to ask, so I’m sorry about that.

Basically, I have two tables (products and stock).

In products, I have two products:

ID: 1 || Name: Top

ID: 2 || Name: Bottom

In stock, I have five stock lines:

ID: 1 || ProductID: 1 || Size: Medium

ID: 2 || ProductID: 1 || Size: Large

ID: 3 || ProductID: 2 || Size: Medium

ID: 4 || ProductID: 3 || Size: 7

ID: 5 || ProductID: 3 || Size: 8

What I need to do is pull out all products with stock, therefore my code at the moment is:

SELECT p.ID, p.Name, s.Size FROM products p JOIN stock s ON s.ProductID = p.ID

This is then pulling the following out:

ID: 1 || Name: Top || Size: Medium

ID: 1 || Name: Top || Size: Large

ID: 2 || Name: Bottom || Size: Medium

ID: 3 || Name: Shoes || Size: 7

ID: 3 || Name: Shoes || Size: 8

What I want to do with this is put the sizes in one column (comma delimited) per ID – thus I want it to look like:

ID: 1 || Name: Top || Size: Medium, Large

ID: 2 || Name: Bottom || Size: Medium

ID: 3 || Name: Shoes || Size: 7, 8

Do anyone know how I can do this? I should know how to do it but my mind has just gone blank!

  • 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-30T13:09:15+00:00Added an answer on May 30, 2026 at 1:09 pm
    SELECT p.ID, p.Name, GROUP_CONCAT(s.Size) AS Size 
    FROM products p 
    JOIN stock s ON s.ProductID = p.ID 
    GROUP BY p.ID
    

    That should work fine.

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

Sidebar

Related Questions

Not really too sure how to word this question, therefore if you don't particularly
Not sure if I'm being too clear with the title. Sorry, it's late and
Sorry if title is not too clear but I think it's about right. NEhow,
Not too sure how to elaborate on this over what the title already states,
Not too sure what's going on here as this doesn't seem like standard practise
I just got a site to manage, but am not too sure about the
I suspect this applies to general ASP.Net too but I am not sure. If
i am not sure if this is a good route to go,...i have some
NOTE: I am not exactly sure how to title or tag this question, so
Okay sorry for the title, wasn't too sure how to phrase it. So we

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.