PHP

PHP reads the database and sorts the implementation code by Chinese name


Sometimes when we read the database output, we may need to sort according to the Chinese user name. The traditional MySQL query code is as follows:


$sql="SELECT * FROM users";// Traditional query mode

The MySQL query code sorted by Chinese user name is as follows:


$sql="SELECT * FROM users ORDER BY CONVERT(name USING gbk)";// In Chinese