完整语法如下
group_concat([DISTINCT] 要连接的字段 [Order BY ASC/DESC 排序字段] [Separator ‘分隔符‘])
SELECT * FROM testgroup
表结构与数据如上
现在的需求就是每个id为一行 在前台每行显示该id所有分数
SELECT id,GROUP_CONCAT(score) FROM testgroup GROUP BY id
SELECT id,GROUP_CONCAT(DISTINCT score) FROM testgroup GROUP BY id
SELECT id,GROUP_CONCAT(score ORDER BY score DESC) FROM testgroup GROUP BY id
SELECT id,GROUP_CONCAT(score SEPARATOR ‘;‘) FROM testgroup GROUP BY id
原文链接:https://blog.csdn.net/qq_35531549/article/details/90383022