MySQL】集約関数GROUP_CONCAT(expr)


SELECT id, user_id FROM group_members where id = 1
id
user_id
1
1
1
2
1
3
1
4
SELECT id, group_concat(user_id separator ',') as members 
  FROM group_members WHERE id = 1 GROUP BY id;
id
members
1
1,2,3,4