数据库有个字段保存了中文名称,比如:
- 张三
- 本山
- 赵本山 ...
现在想通过拼音首字母进行模糊查询:
比如
ZS: 可以查询到张三
BS:可以查找到本山和赵本山
请教,
在数据库已经存在中文名称的数据,且没有保存中文拼音和首字母拼音的前提下。
如何使用 mysql 根据中文名称进行拼音首字母查询到数据。
数据库有个字段保存了中文名称,比如:
现在想通过拼音首字母进行模糊查询:
比如
ZS: 可以查询到张三
BS:可以查找到本山和赵本山
请教,
在数据库已经存在中文名称的数据,且没有保存中文拼音和首字母拼音的前提下。
如何使用 mysql 根据中文名称进行拼音首字母查询到数据。
|
1
是什么阻碍了你建立拼音和首字母列?
|
|
opengpsOct 20, 2020 via Android
2
这种查询一般需要单独一个列来存储首字母,而不是让数据库具备转换拼音能力
|
|
hboliveOct 20, 2020
3
抱歉,开发 MySQL 的人,不认识拼音在这个东东。。
|
|
angeltopOct 20, 2020
4
哈哈,这个国产数据库软件应该是支持的。
|
|
5
mysql 默认支持拼音查询, 你可以查下文档
|
|
xsm1890Oct 20, 2020
6
hahahahahhahahahahaah
|
|
GuangXiNOct 20, 2020 via Android
7
现在能找到开源的库把汉字转换成拼音吧
|
|
freemoonOct 20, 2020
8
别急,这就给 mysql 提 issue
|
|
akagishigeruOct 20, 2020
9
你在建个拼音列不就好了吗
|
|
zhangysh1995Nov 2, 2020
10
@lskjdfgl 老哥厉害了,我去看文档了,还真支持 https://dev.mysql.com/doc/mysql-g11n-excerpt/5.7/en/charset-gb18030.html
gb18030_chinese_ci: The default collation, which supports Pinyin. Sorting of non-Chinese characters is based on the order of the original sort key. The original sort key is GB(UPPER(ch)) if UPPER(ch) exists. Otherwise, the original sort key is GB(ch). Chinese characters are sorted according to the Pinyin collation defined in the Unicode Common Locale Data Repository (CLDR 24). Non-Chinese characters are sorted before Chinese characters with the exception of GB+FE39FE39, which is the code point maximum. |
|
q344766620Jul 28, 2022
11
@zhangysh1995 这是按照拼音排序,无法通过拼音搜索数据库。
|