2017-05-29 57 views
-1
SELECT stc_student.id, group_concat(stc_score.teacher_name) as 评分老师, 
     student_name, ifnull(cast(avg(score) as DECIMAL(18,0)),'') as 平均成绩, 
     student_class,student_worklinks,created_at FROM stc_score 
     RIGHT JOIN stc_student ON (stc_student.id=stc_score.id) 
     GROUP BY stc_student.id ORDER BY 平均成绩 DESC; 

显示:的mysql:非拉丁字符不被倒序排列

+-----------+-------------------------------------------+--------------+--------------+---------------+-----------------------+------------+ 
| id  | 评分老师         | student_name | 平均成绩  | student_class | student_worklinks  | created_at | 
+-----------+-------------------------------------------+--------------+--------------+---------------+-----------------------+------------+ 
| 100160728 | 汤佳,周耀鹏,徐力,李力亚,evilhui   | 王晖   | 64   | 移动1603  | /100160728/index.html | 1493201986 | 
| 100160110 | evilhui         | 刘杰   | 5   | 移动1603  | 111     | 1495566211 | 
| 100160111 | evilhui         | 刘杰   | 5   | 移动1603  | 111     | 1495566211 | 
| 100160112 | evilhui         | 刘杰   | 5   | 移动1603  | 111     | 1495566211 | 
| 100160113 | evilhui         | 刘杰   | 5   | 移动1603  | 111     | 1495566211 | 
| 100160115 | evilhui         | 刘杰   | 5   | 移动1603  | 111     | 1495566211 | 
| 100160705 | evilhui         | 段家峰  | 5   | 移动1601  | /100160705   | 1495812165 | 
| 100160713 | evilhui         | 徐昶   | 5   | 移动1603  | 健康路记录i   | 1495812877 | 
| 343544442 | evilhui         | 刘杰   | 5   | 移动1603  | asdas     | 1495813142 | 
| 425688411 | evilhui         | 王晖   | 5   | 移动1603  | esfer     | 1495815475 | 
| 100160729 | 周耀鹏,evilhui       | 晓杰   | 43   | 移动1603  | /100160728/index.html | 1493201986 | 
| 100160120 | evilhui         | 刘杰   | 33   | 移动1603  | 111     | 1495566211 | 
| 100160114 | evilhui         | 刘杰   | 2   | 移动1603  | 111     | 1495566211 | 
| 100160733 | evilhui         | 王晖   | 10   | 移动1603  | 暂无     | 1495611800 | 
| 111111111 | evilhui         | 吕世惠  | 10   | 移动1601  | 晋中地区昔阳县  | 1495811266 | 
| 123567777 | evilhui         | asd   | 10   | 移动1603  | 123213    | 1495813419 | 
| 434655555 | evilhui         | 阿斯顿  | 10   | 移动1603  | asa     | 1495813337 | 
| 776766666 | evilhui         | 阿斯顿  | 10   | 移动1603  | 还行     | 1495815915 | 
| 987654321 | evilhui         | 最后测试  | 10   | 移动1602  | 欧美style    | 1495814028 | 
| 100001111 | NULL          | 王晖   |    | 移动1603  | NULL     | 1495987456 | 
| 100001112 | NULL          | 王晖   |    | 移动1603  | NULL     | 1495988224 | 
| 100160116 | NULL          | 刘杰   |    | 移动1603  | 111     | 1495566211 | 
| 100160117 | NULL          | 刘杰   |    | 移动1603  | 111     | 1495566211 | 
| 100160118 | NULL          | 刘杰   |    | 移动1603  | 111     | 1495566211 | 
| 100160119 | NULL          | 刘杰   |    | 移动1603  | 111     | 1495566211 | 
| 100160121 | NULL          | 刘杰   |    | 移动1603  | 111     | 1495566211 | 
| 100160122 | NULL          | 刘杰   |    | 移动1603  | 111     | 1495566211 | 
| 10016| NULL          | 刘杰   |    | 移动1603  | 111     | 1495566211 | 
| 100160623 | NULL          | 郭峰斌  |    | 移动1601  | /100160623/index.html | 1495565545 | 
| 100160731 | NULL          | 吕倩   |    | 移动1603  | /100160728/index.html | 1493201986 | 
| 100160922 | NULL          | 王超   |    | 移动1602  | /100160729/index.html | 1493201986 | 
| 100160923 | NULL          | 王超   |    | 移动1603  | /100160729/index.html | 1493201986 | 
| 100200300 | NULL          | 段家风  |    | 移动1603  |      | 1495999675 | 
| 123134444 | NULL          | 王晖   |    | 移动1603  | NULL     | 1495566211 | 
| 130120110 | NULL          | 吕林   |    | 移动1603  | NULL     | 1495999675 | 
+-----------+-------------------------------------------+--------------+--------------+---------------+-----------------------+------------+ 

平均成绩`列没有排序

回答

0

检查实际的MySQL服务器my.cnf文件。下面将整个链条设置为UTF-8:在MySQL使用UTF-8

[client] 
default-character-set=utf8mb4 

[mysql] 
default-character-set=utf8mb4 

[mysqld] 
collation-server = utf8mb4_unicode_ci 
init-connect='SET NAMES utf8mb4' 
character-set-server = utf8mb4 
+0

停止,[**使用'UTF8mb4' **代替(https://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – Martin

+0

@Martin是的!完全正确,我的不良有需要更新...非常感谢你 –

相关问题