› MySQL 5.5 Community Server
› MySQL 5.6 Community Server
› Percona Configuration Wizard
› XtraBackup 搭建主从复制
Great Sites on MySQL
› Percona
› MySQL Performance Blog
› Severalnines
推荐管理工具
› Sequel Pro
› phpMyAdmin
推荐书目
› MySQL Cookbook
MySQL 相关项目
› MariaDB
› Drizzle
参考文档
› http://mysql-python.sourceforge.net/MySQLdb.html
Vimax
V2EX  ›  MySQL

mysql 如何根据中文拼音首字母进行中文查询?

  •  
  •   Vimax · Oct 20, 2020 · 5243 views
    This topic created in 2210 days ago, the information mentioned may be changed or developed.

    数据库有个字段保存了中文名称,比如:

    1. 张三
    2. 本山
    3. 赵本山 ...

    现在想通过拼音首字母进行模糊查询:

    比如

    ZS: 可以查询到张三

    BS:可以查找到本山和赵本山

    请教,

    在数据库已经存在中文名称的数据,且没有保存中文拼音和首字母拼音的前提下。

    如何使用 mysql 根据中文名称进行拼音首字母查询到数据。

    11 replies  •  2022-07-28 21:35:23 +08:00
    Caskia
    Caskia
    Oct 20, 2020❤️6
    1
    是什么阻碍了你建立拼音和首字母列?
    opengps
    opengps
    Oct 20, 2020 via Android
    2
    这种查询一般需要单独一个列来存储首字母,而不是让数据库具备转换拼音能力
    hbolive
    hbolive
    Oct 20, 2020
    3
    抱歉,开发 MySQL 的人,不认识拼音在这个东东。。
    angeltop
    angeltop
    Oct 20, 2020
    4
    哈哈,这个国产数据库软件应该是支持的。
    lskjdfgl
    lskjdfgl
    Oct 20, 2020❤️1
    5
    mysql 默认支持拼音查询, 你可以查下文档
    xsm1890
    xsm1890
    Oct 20, 2020
    6
    hahahahahhahahahahaah
    GuangXiN
    GuangXiN
    Oct 20, 2020 via Android
    7
    现在能找到开源的库把汉字转换成拼音吧
    freemoon
    freemoon
    Oct 20, 2020
    8
    别急,这就给 mysql 提 issue
    akagishigeru
    akagishigeru
    Oct 20, 2020
    9
    你在建个拼音列不就好了吗
    zhangysh1995
    zhangysh1995
    Nov 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.
    q344766620
    q344766620
    Jul 28, 2022
    11
    @zhangysh1995 这是按照拼音排序,无法通过拼音搜索数据库。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   528 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 19:56 · PVG 03:56 · LAX 11:56 · JFK 14:56
    ♥ Do have faith in what you're doing.