在utf-8编码的情况下,首字母可能是中文或者英文,英文排在前头,中文排在后面,中文需要按照拼音顺序排序,请问如何实现?
如果是GBK编码的,可以直接对字段进行order by ,但是纯utf-8环境下不行。于是在网上找到了如下两种方法,我试的是第二种,还不错。

Ruby代码


conv = Iconv.new("GBK", "utf-8")  




mysql:

Sql代码

SELECT * FROM table ORDER BY CONVERT( NAME  USING gbk ) ;
Tags: ,
代码编程 | 评论(0) | 引用(0) | 阅读(161)
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]