Home > Backend Development > PHP Tutorial > PHP读取数据库并按照中文名称进行排序实现代码_php技巧

PHP读取数据库并按照中文名称进行排序实现代码_php技巧

WBOY
Release: 2016-05-17 09:06:58
Original
1074 people have browsed it

有时候我们读取数据库输出的时候可能会需要按照中文用户名的方式进行排序,传统的MySQL查询代码如下:

复制代码 代码如下:

$sql="SELECT * FROM users";//传统查询方式

按照中文用户名进行排序的MySQL查询代码如下:
复制代码 代码如下:

$sql="SELECT * FROM users ORDER BY CONVERT(name USING gbk)";//按照中文用
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