Get Chinese pinyin in MySQL or convert Chinese to PinYin

Source: Internet
Author: User
Obtain the Chinese pinyin in MySQL or convert the Chinese to the Chinese pinyin MySQL ------------------------------------- page: select * fromxxxlimit0, 10 ???? Limitstart, pagesize? -------------------------------------? INSERTINTOperson_info? SELECT? U. uid ,? U. disp

Obtain Chinese pinyin in MySQL or convert Chinese to Chinese MySQL --------------------------------------------- page: select * from xxx limit? ? ? ? Limit start, pagesize? -------------------------------------? Insert into person_info? SELECT? U. uid ,? U. disp

Obtain Chinese pinyin in MySQL or convert Chinese to PinYin

MySQL

-------------------------------------

Paging: select * from xxx limit 0, 10

? ? ? ? Limit start, pagesize

?

-------------------------------------

?

Insert into person_info

?

SELECT

? U. uid,

? U. displayname,

??

? ? ? ? ? ELT (INTERVAL (CONV (HEX (LEFT (CONVERT (u. displayname USING gbk), 1), 16, 10 ),

? ? ? ? 0xB0A1, 0xB0C5, 0xB2C1, 0xB4EE, 0xB6EA, 0xB7A2, 0xB8C1, 0xB9FE, 0xBBF7,

? ? ? ? 0xBFA6, 0xC0AC, 0xC2E8, 0xC4C3, 0xC5B6, 0xC5BE, 0xC6DA, 0xC8BB, 0xC8F6,

? ? ? ? 0 xCBFA, 0 xCDDA, 0xCEF4, 0xD1B9, 0xD4D1 ),

? ? ? ? 'A', 'B', 'C', 'D', 'E', 'E', 'F', 'G', 'h', 'J', 'k ', 'l', 'M', 'n', 'O', 'P ',

? ? ? ? 'Q', 'R', 's', 't', 'w', 'x', 'y', 'z') as py,

??

? REPLACE (ui. sex, 'male', '1'), 'female, '0 '),

? CONCAT (ui. birth_year, '-', ui. birth_month, '-', ui. birth_day ),

? Ui. residence_city,

? Ui. createdate,

? Ui. createdate

From user u,

? User_info ui

WHERE u. type = 1

? ? AND u. uid = ui. uid

?

-------------------------------------

Obtain Chinese pinyin in MySQL or convert Chinese to PinYin

?

Example:

1? ? ? ? Select *,

2? ? ? ? ELT (INTERVAL (CONV (HEX (left (CONVERT (FieldName USING gbk), 1), 16,10 ),

3? ? ? ? 0xB0A1, 0xB0C5, 0xB2C1, 0xB4EE, 0xB6EA, 0xB7A2, 0xB8C1, 0xB9FE, 0xBBF7,

4? ? ? ? 0xBFA6, 0xC0AC, 0xC2E8, 0xC4C3, 0xC5B6, 0xC5BE, 0xC6DA, 0xC8BB, 0xC8F6,

5? ? ? ? 0 xCBFA, 0 xCDDA, 0xCEF4, 0xD1B9, 0xD4D1 ),

6? ? ? ? 'A', 'B', 'C', 'D', 'E', 'E', 'F', 'G', 'h', 'J', 'k ', 'l', 'M', 'n', 'O', 'P ',

7? ? ? ? 'Q', 'R', 's', 't', 'w', 'x', 'y', 'z') as PY

8? ? ? ? FROM DataTable

?

Note:

?

ELT (N, str1, str2, str3 ,...)

If N = 1, the return value is str1. If N = 2, the return value is str2, and so on.

?

INTERVAL (N, N1, N2, N3 ,...)

N1, N2, N3 ,... Is an ascending ordered integer. Returns the position of N in an ordered integer.

?

CONV (N, from_base, to_base)

Convert numbers between different bases. The return value is the N string of the number, which is converted from from_base to to_base base. In this example, convert hexadecimal to decimal.

?

CONVERT (FieldName USING gbk)

Convert data to the gbk character set.

?

HEX (CHAR)

Returns the hexadecimal number of characters.

?

LEFT (STR, N)

Returns the N characters starting from the left of the STR string.

?

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.