Group Concat is used in MySQL to get concatenated values of expressions with more than one result per column. Meaning, there are many rows to be selected back for one column such as Name(1):Score(*)
Name | Score |
---|---|
Adam | A+ |
Adam | A- |
Adam | B |
Adam | C+ |
Bill | D- |
John | A- |
SELECT Name, GROUP_CONCAT(Score ORDER BY Score desc SEPERATOR ' ') AS Grades
FROM Grade
GROUP BY Name
Results:
+------+------------+
| Name | Grades |
+------+------------+
| Adam | C+ B A- A+ |
| Bill | D- |
| John | A- |
+------+------------+