The following describes how to query the initials of Chinese characters and Pinyin in MySQL. This method is very useful. If you have encountered similar problems before, take a look.
To query the initials of Chinese characters and Pinyin in MySQL, follow these steps:
1. Create a pinyin initials data table
SQL code:
Drop table if exists 'pinin ';
Create table 'pinin '(
'Py' varchar (1 ),
'Hz1 'varchar (1 ),
'Hz2' varchar (1)
);
Insert into 'pinin' ('py', 'hz1 ', 'hz2') VALUES
('A', 'tag', 'tag '),
('B', '8', 'book '),
('C', 'hangzhou', 'hangzhou '),
('D', 'taobao', 'taobao '),
('E', 'hangzhou', 'hangzhou '),
('F', 'F', 'hangzhou '),
('G', 'hangzhou', 'hangzhou '),
('H', 'hangzhou', 'hangzhou '),
('J', 'day', 'hangzhou '),
('K', 'hangzhou', 'hangzhou '),
('L', 'hangzhou', 'hangzhou '),
('M', 'M', 'M '),
('N', 'hangzhou', 'hangzhou '),
('O', 'ou', 'hangzhou '),
('P', 'taobao', 'exposing '),
('Q', '7', 'q '),
('R', 'hangzhou', 'hangzhou '),
('S ', 'alipay', 'alipay '),
('T', 'Ta', 'hangzhou '),
('W', 'two', 'two '),
('X', 'Xi ', 'hangzhou '),
('Y', 'ya ', 'taobao '),
('Z', 'taobao', 'taobao ');
After execution, check whether there are "?" data records in the added table. Question mark. If yes, the database encoding is incorrect.
PY HZ1 HZ2
A challenge
B
C branch networks
D zookeeper
E branch networks
F producer
G branch networks
H branch networks
J.
K branch networks
L zookeeper
M branch networks
N branch networks
O
P branch exposure
Q qizhen
R branch networks
S branch networks
T he Yi
W Yunxiao
X Xi Jinping
Y Branch
Z branch networks
2. MySQL queries the first Chinese Character and alphabet in the database table
SELECT 'pinyin'. py, 'corresponding Table '.*
FROM 'corresponding table', 'pinin'
WHERE 'Chinese character title'> = 'hz1'
AND 'Chinese character title' <= 'hz2 ';
Example of query results:
Py Chinese Character title
Z recruitment
Z topics
W website Introduction
W ask
S search
L contact information
L Forum
H Member
G about us
B. Copyright Notice
Encyclopedia B
You can also directly use MySQL to query the first Chinese Character and alphabet of Chinese characters.
SELECT 'pinin'. py
FROM 'pinin'
WHERE 'Chinese character '> = 'hz1'
AND 'Chinese characters' <= 'hz2 ';
The query result is "H"
MySQL table lock status and number of opened files
View the processes of the MySQL server
How to enable MySQL slow Query
Mysql multi-Table query implementation
How to Create MySQL Functions