Home > Backend Development > PHP Tutorial > MySQL's like problem, super powerful kill record! ! ! _PHP Tutorial

MySQL's like problem, super powerful kill record! ! ! _PHP Tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:57:31
Original
938 people have browsed it

Method 1:
The solution is to add the "binary" attribute to the field containing Chinese to make it a binary comparison, for example, change "name char(10)" to "name char(10)binary".
Method 2:
If you use source code to compile MySQL, you can use the --with--charset=gbk parameter when compiling MySQL, so that MySQL will directly support Chinese search and sorting.
Method 3:
You can use Mysql’s locate function to judge. Taking the above problem as an example, the usage method is:
SELECT * FROM table WHERE locate(field,'李') > 0;
Method 4:
Change your Select statement to this, SELECT * FROM TABLE WHERE FIELDS LIKE BINARY '%FIND%' can

The reason for the problem is: In MySQL, when sorting and searching Chinese characters, the sorting and search results of Chinese characters are wrong. This situation exists in many versions of MySQL. If this problem is not solved, then MySQL will not be able to actually handle Chinese.
The reason for this problem is: MySQL is case-insensitive when querying strings. When compiling MySQL, the ISO-8859 character set is generally used as the default character set. Therefore, during the comparison process, the Chinese encoding character size Write conversion causes this phenomenon

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317782.htmlTechArticleMethod 1: The solution is to add the "binary" attribute to the field containing Chinese to make it a binary comparison. For example, change "namechar(10)" to "namechar(10)binary". Method 2: If you use...
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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template