Home > Database > Mysql Tutorial > mysql中文字段utf8排序

mysql中文字段utf8排序

WBOY
Release: 2016-06-07 14:56:53
Original
1089 people have browsed it

无 在开发中遇到这样一个问题,再按照某一字段排序时,遇到中文时字段排序很乱,没有按照字典表的降序或者升序排列(数据库字段采用utf-8)。在不改变数据库情况下可以采取如下方式:select * from test order by convert(sortname using gbk) desc;这样就会

 
在开发中遇到这样一个问题,再按照某一字段排序时,遇到中文时字段排序很乱,没有按照字典表的降序或者升序排列(数据库字段采用utf-8)。在不改变数据库情况下可以采取如下方式:
select * from test order by convert(sortname using gbk) desc;
这样就会单独用gbk编码对sortname排序,而不影响字段本身编码。
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template