在mysql数据库中中文排序

来源:互联网 发布:中国气象数据网账号 编辑:程序博客网 时间:2024/06/02 04:32

今天遇到要中文排序的问题。直接用order by name 发现不行。查找资料原来是编码问题,转成gb2312即可。

select name from test1 order by convert(name using gb2312) asc;

在thinkphp 中写法为:

$Customer->distinct(true)->field("customer_name")->order("convert(customer_name using gb2312) ")->select();