MySQL实现 group_concat 排序

 

 

MySQL支持实现group_concat() 内部自定义排序:

 

实例:

新建一张表 reward,表中数据如下:

 

SQL:

SELECT uid, GROUP_CONCAT(money ORDER by money DESC) AS money_desc FROM reward GROUP BY uid DESC;

 

 

使用其他字段也一样的效果:

SQL:

SELECT uid, GROUP_CONCAT(id ORDER by money DESC) AS id_money_desc FROM reward GROUP BY uid DESC;

 

posted @ 2022-05-01 19:35  幽篁晓筑  阅读(206)  评论(0编辑  收藏  举报