How to perform a fuzzy query on fields 37,65535 in Chinese

Source: Internet
Author: User
In analyticdb 5.2, if you use SQL to create a table and set the field attribute to ccsid 65535, you can perform fuzzy queries in Chinese. However, if you use DDS to create a table, use field level keyword to set the field attribute to ccsid.
(65535), then the Chinese fuzzy query cannot be used, because 0e/0f control code is also used as a common character.

For example
R Test
-Name -- A (20) -- ccsid (65535)

Create a PF file qgpl/test

Insert into qgpl/test values ('People's Republic of China ')

Fuzzy query using query
Select * From qgpl/test where name like '%'
The system returns zero rows of records.

To perform fuzzy query on the 65535 field, you must modify the query syntax:
Select * From qgpl/test where hex (name) Like SUBST (hex ('中'), 1, 3) | '%'
The returned result is
-------- People's Republic of China
The returned result is correct.

The processing process of Simplified Chinese in a single-byte environment is fully considered, that is, a dual-byte character (with 0e/0f Control Code) is treated as four bytes, the data contained in these bytes cannot be correctly parsed in a single-byte environment. Therefore, the hexadecimal format must be used for processing.

If you want to search for "Zhonghua", the search conditions must be written as follows:
Select * From qgpl/test where hex (name) Like SUBST (hex ('中'),) | '%'

Because 0e/0f only appears at the beginning and end of a double-byte string, the number of characters to be retrieved for two Chinese characters is 5.

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.