【问题标题】:With utf8mb4 collation different characters are equal in "where" condition使用 utf8mb4 排序规则,不同的字符在“where”条件下是相等的
【发布时间】:2017-08-02 06:19:52
【问题描述】:

字段“名称”是 utf8mb4_unicode_ci 排序规则。当我查询时:

SELECT * FROM `tags` WHERE `name` = 'kliutys'

选择值为“kliūtys”的记录。如何让 mysql 选择完全匹配并将 'ū' 视为与 'u' 不同的字符?

【问题讨论】:

    标签: mysql utf8mb4


    【解决方案1】:

    我建议将tags 列排序规则更改为utf8mb4_bin

    其他选项是在选择中指定排序规则:

    SELECT * FROM `tags` WHERE `name` COLLATE utf8mb4_bin = 'kliutys'

    更多信息: https://dev.mysql.com/doc/refman/5.7/en/charset-collate.html

    【讨论】:

      猜你喜欢
      • 2023-03-17
      • 2018-12-19
      • 2018-09-30
      • 2014-08-07
      • 2020-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-11
      相关资源
      最近更新 更多