PHP reads the database and sorts the implementation code by Chinese name
- 2020-05-27 04:37:27
- OfStack
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:
The MySQL query code sorted by Chinese user name 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