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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:22:56+00:00 2026-05-17T21:22:56+00:00

I think I have done this before, but it could also be a function

  • 0

I think I have done this before, but it could also be a function of PHP. What I would like is to do a MySQL query (in a MySQL client, not PHP) and get for example

Foo    A
       B
       C
Bar    B
       D
       E

Instead of

Foo    A
Foo    B
Foo    C
Bar    B
Bar    D
Bar    E

This would of course only make sence if it was ordered by that first column. Not sure if it is possible, but like I said, I mean to remember to have done this once, but can’t remember how or if it was through some PHP “magic”…


Update: Suddenly remembered where I had used it. What i was thinking of was the WITH ROLLUP modifier for GROUP BY. But I also discovered that it doesn’t do what I was thinking here, so my question still stands. Although I don’t think there is a solution now. But smart people have proved me wrong before 😛


Update: Should probably also have mentioned that what I want this for is a many-to-many relationship. In the actual select Foo would be the first name of an attendee and I would also want last name and some other columns. The A, B, C, D, E are options the attendee has selected.

attendee (id, first_name, last_name, ...)
attendees_options (attendee_id, option_id)
option (id, name, description)
  • 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-17T21:22:57+00:00Added an answer on May 17, 2026 at 9:22 pm

    This will give you

    Foo    A,B,C
    Bar    B,D,E    
    
    SELECT column1, GROUP_CONCAT(column2) FROM table GROUP BY column1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT 1 : I think I was not clear myself before and hence could
I kind of posted a similar question a couple of days ago but that
I am trying to create a moderately complex web page. This is not something
I know, there are some similar questions to the following out there, but I
When working with 3d graphics, sample shaders USUALLY use the following operation for vector
A lot of c/malloc()'s in a for/while/do can consume a lot of time so
Currently I am going through a Sams learn Android SDK in 24 hours book
I am using the Nov version of the AjaxControlToolkit, and I found a logic
I'm predominately a Java guy, which is why I need some assistance on what
Updated title to better reflect what I'm trying to do. In short, there are

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.