Php-mysql Query of undecoded unicode Chinese characters, fuzzy query failed

Source: Internet
Author: User
In the basic information of students in the database, the student name field is a json-packed string, for example, {& quot; stu_name & quot;: & quot; u5f20u4e09 & quot ;}, it indicates that the student name is Michael. I want to perform a fuzzy query on the student name in the php program. when I enter & quot; Zhang & quot;, the background program uses json_encode to get the unicode u5f20, then, the fuzzy query condition in the database is like & #39; % u5f20 % & #39;. at this time, the data of Michael can be returned, but when I enter & quot; when Zhang San & quot; is two words, like phpsql fuzzy query

In the basic information of students in the database, the student name field is a json-packed string, for example, {"stu_name": "\ u5f20 \ u4e09"}, indicating that the student name is John. I want to perform a fuzzy query on the student name in the php program. when I enter "Zhang", the background program uses json_encode to get the unicode \ u5f20, then, the fuzzy query condition in the database is like '% \ u5f20 %'. at this time, the data of Michael can be returned, but when I enter the word "Michael, like '% \ u5f20 \ u4e09 %', it cannot be returned. After several attempts, I found that only one Chinese character can be found between two % characters. In addition, insert a % between Chinese characters and like '% \ u5f20 % \ u4e09 %. I used var_dump ('\ u5f20 \ u4e09') to output 12 characters. There should be no other characters between Chinese characters. what is the problem? Please advise.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.