是否可以通过选择查询得到类似的内容
| firstfield | secondfield | types
firstvalue secondvalue 1,2,3
而不是
| firstfield | secondfield | type
firstvalue secondvalue 1
firstvalue secondvalue 2
firstvalue secondvalue 3
感谢您的帮助。
最佳答案
您可以使用group_concat :
select firstfield, secondfield, GROUP_CONCAT(type order by type) as types
from yourtable
group by firstfield, secondfield;
关于MySQL,对 SELECT 结果中的行进行分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37440739/