Home > Database > Mysql Tutorial > Mysql 中文字段排序( 按拼音首字母排序) 的查询语句_MySQL

Mysql 中文字段排序( 按拼音首字母排序) 的查询语句_MySQL

WBOY
Release: 2016-06-01 13:10:22
Original
1272 people have browsed it

如果数据表tbl的某字段name的字符编码是latin1_swedish_ci
select * from `tbl` order by birary(name) asc ;
 
如果数据表tbl的某字段name的字符编码是utf8_general_ci
 
SELECT name FROM `tbl` WHERE 1 ORDER BY CONVERT( name USING gbk ) COLLATE gbk_chinese_ci ASC
 
===================
$orderby="convert(`group` USING gbk) COLLATE gbk_chinese_ci,displayorder,navid"

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