0

I have a table structure that looks like this:

ID   String
-----------
1     A
1     Test
1     String
2     Dear
2     Person

I need the final output to look like this:

ID  FullString
--------------------
1   A, Test, String
2   Dear, Person

I am really lost on how to approach this... I looked on a couple examples online but they seemed to be VERY complex... this seems like it should be a real easy problem to solve in sql.

Thank you for all assistance!

Nebbing
  • 47
  • 7
Dave C
  • 399
  • 2
  • 6
  • 13
  • possible duplicate of http://stackoverflow.com/questions/149772/how-to-use-group-by-to-concatenate-strings-in-mysql – OMG Ponies Apr 28 '10 at 18:49
  • Check this out: http://stackoverflow.com/questions/149772/how-to-use-group-by-to-concatenate-strings-in-mysql – mwilson Apr 28 '10 at 18:45

1 Answers1

0
 SELECT ID, GROUP_CONCAT(String) AS FullString
     FROM TABLE
     GROUP BY ID

There are additional parameters available for GROUP_CONCAT to control sequence and separation. GROUP_CONCAT is MySQL specific.

Larry Lustig
  • 49,320
  • 14
  • 110
  • 160