Home >Database >Mysql Tutorial >How to convert Chinese to Pinyin in mysql

How to convert Chinese to Pinyin in mysql

藏色散人
藏色散人Original
2020-10-28 09:18:004755browse

Mysql method of converting Chinese to Pinyin: First create a database and create a Chinese character and Pinyin comparison table; then use the "INSERT INTO t_base_pinyin () VALUES ()" statement to add a comparison to the Chinese Pinyin comparison table Data; finally create a function that converts Chinese characters into pinyin.

How to convert Chinese to Pinyin in mysql

Recommended: "mysql video tutorial"

The first step is to open the software and create a database, as follows As shown in the picture:

How to convert Chinese to Pinyin in mysql

# After creating the database in the second step, you need to create a Chinese character and pinyin comparison table, and use the create table statement to create the table, as shown in the following figure:

How to convert Chinese to Pinyin in mysql

In the third step, we open the table and we can see that a table named t_base_pinyin has been successfully created and contains two fields: pin_yin_ and code_, as shown in the following figure:

How to convert Chinese to Pinyin in mysql

In the fourth step, we use the INSERT INTO t_base_pinyin () VALUES () statement to add comparison data to the Chinese pinyin comparison table, as shown in the following figure:

How to convert Chinese to Pinyin in mysql

In the fifth step, we open t_base_pinyin, and we can see that the control data has been inserted successfully, as shown in the figure below:

How to convert Chinese to Pinyin in mysql

In the sixth step, we finally need Create a function that converts Chinese characters into pinyin, and executes it after the input is completed. The statement is as shown in the figure below

How to convert Chinese to Pinyin in mysql

In the seventh step, we enter the select to_pinyin('test') statement to query. You can see that the output to_pinyin('test'),ceshi, has successfully converted Chinese into Pinyin, as shown in the figure below:

How to convert Chinese to Pinyin in mysql

The above is the detailed content of How to convert Chinese to Pinyin in mysql. For more information, please follow other related articles on the PHP Chinese website!

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