美文网首页
mysql使用 utf8mb4 问题

mysql使用 utf8mb4 问题

作者: costa92 | 来源:发表于2019-06-12 15:41 被阅读0次

错误信息:

 Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation '='

原因:

utf8mb4_unicode_ci和utf8mb4_general_ci列不能混合查询!!!!这个时候我们就要把字符集改为相同的才能进行查询!

解决方法:
我们可以在查询的时候指定等号一边的字符集编码

格式:WHERE 列名 COLLATE utf8mb4_unicode_ci = 嵌套语句
或者:WHERE 列名 = 嵌套语句 COLLATE utf8mb4_unicode_ci 达到让两边的字符集相等!

eg:

SELECT * FROM tb1
LEFT JOIN tb2 ON tb1.username = tb2.username COLLATE utf8mb4_unicode_ci 

相关文章

网友评论

      本文标题:mysql使用 utf8mb4 问题

      本文链接:https://www.haomeiwen.com/subject/paylfctx.html