一、 GROUP_CONCAT 的完整语法如下:
group_concat([DISTINCT] 要连接的字段 [Order BY ASC/DESC 排序字段] [Separator '分隔符'])
默认的分割符为:","
数据准备:
SELECT
s_id,
s_score
FROM
score
WHERE
s_score IS NOT NULL
二、 问题 以每个s_id为一行 在前台每行显示该s_id对应的所有分数
SELECT
s_id,
GROUP_CONCAT( s_score ORDER BY s_score DESC SEPARATOR ';' ) all_score
FROM
score
WHERE
s_score IS NOT NULL
GROUP BY
s_id;