gpt4 book ai didi

mysql - 从 varchar 列搜索表情符号返回不同的记录

转载 作者:行者123 更新时间:2023-11-29 01:37:50 25 4
gpt4 key购买 nike

我使用的是MySQL5.6。数据库字符集是 utf8mb4。当我如下搜索表情符号时,我得到了意想不到的结果。

mysql> SELECT id, hex(title) FROM tags WHERE title = 0xF09F9886;
+-----+------------+
| id | hex(title) |
+-----+------------+
| 165 | F09F9886 |
| 166 | F09F9884 |
+-----+------------+

它应该只返回 id=165。有谁知道这是为什么?

最佳答案

我找到了解决方法。这是整理的问题。我使用默认排序规则值,我假设它是 utf8mb4_general_ci。当我更改那个 utf8mb4_bin 时,MySQL 返回了正确的结果。

您可以如下更改排序规则。

ALTER TABLE tablename CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;

关于mysql - 从 varchar 列搜索表情符号返回不同的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35010052/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com