Mysql Chinese sorting problem

xiaoxiao2021-03-13  195

MySQL If you are sorted by a field with Chinese characters, the result is wrong.

Cause: MySQL is not sensitive when querying the string, usually in the ISO-8859 character set as the default character set when finishing MySQL, so the Chinese character encoding character case case in the comparison causes this phenomenon.

There are two solutions on the online query:

1. Plus "binary" attributes with the "binary" attribute containing the Chinese, so as binary comparisons.

Create Table TestTable (ID INT (11) Not Null Auto_Increment, Name Varchar (60) Binary Default Null, Primary Key (ID)) TYPE = MyISAM;

2, use -with - charset = GBK parameters while compiling mysql source code, so mysql will directly support Chinese finding and sorting. --with - charset = GBK ratio --with - charset = GB2312 is good. The default is Latin1, compiles EXTRA-CHARSETS = GB2312, GBK, where it is used to join multiple character sets.

The first method was tested in MySQL 4.0.

转载请注明原文地址:https://www.9cbs.com/read-129076.html

New Post(0)