Home >Database >Mysql Tutorial >在MySQL中获取中文的拼音或转换中文替拼音

在MySQL中获取中文的拼音或转换中文替拼音

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 16:15:451585browse

在MySQL中获取中文的拼音或转换中文为拼音 MySQL ------------------------------------- 分页:select * from xxx limit 0,10 ? ? ? ? limit start,pagesize ? ------------------------------------- ? INSERT INTO person_info ? SELECT ? u.uid, ? u.disp

在MySQL中获取中文的拼音或转换中文为拼音

MySQL

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

分页: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,

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

? ? ? ? 'A','B','C','D','E','F','G','H','J','K','L','M','N','O','P',

? ? ? ?'Q','R','S','T','W','X','Y','Z') AS PY,

??

? REPLACE(REPLACE(ui.sex, '男', '1'),'女','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

?

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

在MySQL中获取中文的拼音或转换中文为拼音

?

示例:

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 ? ? ? ?0xCBFA,0xCDDA,0xCEF4,0xD1B9,0xD4D1),

6 ? ? ? ?'A','B','C','D','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

?

说明:

?

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

若N = 1,则返回值为 str1 ,若N = 2,则返回值为 str2 ,以此类推。

?

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

N1,N2,N3,…为递增的有序整数。函数返回N在有序整数中的位置。

?

CONV(N,from_base,to_base)

不同数基间转换数字。返回值为数字的N字符串表示,由from_base基转化为 to_base 基。本例中为将十六进制转换为十进制。

?

CONVERT(FieldName USING gbk)

将数据转换为gbk字符集。

?

HEX(CHAR)

返回字符的十六进制数。

?

LEFT(STR,N)

取STR字符串左边开始的N个字符。

?

Statement:
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