Mysql queries Chinese data

Source: Internet
Author: User
For mysql to query Chinese data, I have a large table data volume, and the name field data is both Chinese and English. now I want to find out which data is Chinese ?, First standardize the statement: this & quot; Chinese & quot; although we usually make it clear, it is not so clear on the computer .... in utf8, Chinese characters are placed together with Korean and Japanese characters, collectively referred to as cjk... in fact, it also includes some full-angle symbols .. mysql queries Chinese data
I have a large table with a large amount of data, and the name field has Chinese and English Data. now I want to find out which data is Chinese?

------ Solution --------------------
First, standardize the statement:
Although the meaning of this "Chinese" is clear at ordinary times, it is not so clear on the computer ....
In utf8, Chinese characters are put together with Korean and Japanese characters, collectively referred to as cjk... in fact, they also include some full-angle symbols...

In utf8, Chinese characters are basically in the 3-byte zone, and some 4-byte characters are not uncommon,
At the same time, there are still Indian characters in the 3-byte area... because you don't use them, they don't matter...

So let's make it simpler. Suppose you want to find all records with "3-byte utf8 characters ".

You can use this
Name regexp concat ('[', char (0xE0), '-', char (0xEF), '] [', char (0x80 ),'-', char (0xBF), '] [', char (0x80), '-', char (0xBF), ']')

Note that \ xXX cannot be used directly in mysql regular expressions, so char and concat... google cannot find a more convenient method...


In addition, I do not know whether your data contains 2-byte characters (European Greek Latin characters, etc ),
If you are sure there are no... OK !!!
That is to say, apart from single-byte ascii characters, your data is a 3-byte Chinese character ....

You can use a simple method:
Char_length (name )! = Length (name)



------ Solution --------------------
The REGEXP of mysql is not very powerful. try [^ [: alnum:] [: cntrl:] [: space:].

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.