MySQL - Select concatenate 2 values with 1 id
For example, I have a table 'Map':
Map: id | place __________ 1 | a 1 | b 2 | a 2 | b 2 | c
What MySQL query can I use for me to have the following results:
id | place __开发者_C百科________ 1 | a,b 2 | a,b,c
You should use the group_concat() function for this. You can use it as follows.
SELECT id,group_concat(DISTINCT place ORDER BY place ASC SEPARATOR ',')
FROM Map
GROUP BY ID
精彩评论