Back
Basically, the question is how to get from this:
id string1 A1 B2 C
id string
1 A
1 B
2 C
to this:
id string1 A B2 C
1 A B
Try this code:
SELECT id, GROUP_CONCAT(string SEPARATOR ' ') FROM table GROUP BY id;
You can refer to this link http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat
GROUPCONCAT: This function returns a string result with the concatenated non-NULL values from the group. This returns NULL if there are no non-NULL values.
31k questions
32.8k answers
501 comments
693 users