views:

391

answers:

2
+5  A: 

Sure, see http://dev.mysql.com/doc/refman/...tions.html#function_group-concat:

SELECT student_name,
  GROUP_CONCAT(DISTINCT test_score ORDER BY test_score DESC SEPARATOR ' ')
  FROM student
  GROUP BY student_name;
Jonathan Sampson
+1, faster than me :)
Paul Dixon
Thanks, Paul. I'm all coffee'd up this morning ;)
Jonathan Sampson
Ivarska, update your original post with your example query.
Jonathan Sampson
Done. Sad that you can't put code in comments...
Ivarska
Your code is heavily relied upon for your specific answer, and therefore should not be placed anywhere but your original post. If you put it here in this comment, many programmers here won't see it, and you won't get the best possible response :)
Jonathan Sampson
Sad but true. :) Is that code enough or should I write the whole query?
Ivarska
I've updated my answer.
Jonathan Sampson
I tested that after your first post and it didn't work.
Ivarska
Did you try ASC instead of DESC?
Jonathan Sampson
I didn't use either of them (ASC = default).
Ivarska
+1  A: 

do you mean to order by ?

SELECT _key, COUNT(*) as cnt, GROUP_CONCAT(_value ORDER BY _value SEPARATOR ', ') as value_list FROM group_concat_test GROUP BY _key ORDER BY _key;

Haim Evgi