我在DB中有以下信息:
id | name | company
---+----------+------
1 | Joe | company_1
2 | Sally | company_2
3 | Marc | company_3
4 | Bob | company_1
可以在SQL中执行类似的操作:
SELECT company, _something_ FROM my_db GROUP BY company
得到:
company | members
---------- | ---------
company_1 | Joe, Bob
company_2 | Sally
company_3 | Marc
提前感谢您的帮助!
答案 0 :(得分:0)
<强> MySQL的:强>
SELECT company, GROUP_CONCAT(name SEPARATOR ',') AS members FROM my_table GROUP BY company