如何在MySQL中为日语设置模式排序规则
作者:互联网
我有整理问题.我想设置整理以支持日语.例如,当table.firstname具有“あ”时,带有“ぁ”的查询应返回记录.提前致谢.
解决方法:
这就像“大写”和“小写”,对吗?
mysql> SELECT 'あ' = 'ぁ' COLLATE utf8_general_ci;
+---------------------------------------+
| 'あ' = 'ぁ' COLLATE utf8_general_ci |
+---------------------------------------+
| 0 |
+---------------------------------------+
mysql> SELECT 'あ' = 'ぁ' COLLATE utf8_unicode_ci;
+---------------------------------------+
| 'あ' = 'ぁ' COLLATE utf8_unicode_ci |
+---------------------------------------+
| 1 |
+---------------------------------------+
mysql> SELECT 'あ' = 'ぁ' COLLATE utf8_unicode_520_ci;
+-------------------------------------------+
| 'あ' = 'ぁ' COLLATE utf8_unicode_520_ci |
+-------------------------------------------+
| 1 |
+-------------------------------------------+
我建议将列更改为COLLATION utf8_unicode_520_ci(或utf8mb4_unicode_520_ci).
如果您希望包含中文,请务必使用utf8mb4. (也许这个建议也适用于汉字.)
标签:mysql,collation 来源: https://codeday.me/bug/20191008/1872731.html