Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_unicode_ci,IMPLICIT) for operat

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

今天写了一个简单的sql,报了如上错误。一度让我怀疑人生,这么简单的sql都写不好吗?

一经查证,原来是进行比较的两个字段的字符集编码不同导致。

解决办法:

1:修改其中的一个字符集,对于表结构进行更改。

2: 在其中的一个列后面加上 COLLATE utf8mb4_unicode_ci/utf8mb4_general_ci 进行指定。

注意:这种情况是不应该出现的,在进行表结构设计更改时,字符集应该统一

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个错误提示是与MySQL数据库中的字符集(collation)相关的问题。它表示在进行比较操作时,出现了不同的字符集的混合。通常,这个错误会出现在数据库查询语句中的操作符(比如=、<>等)的两边使用了不同的字符集。比如,utf8mb4_general_ciutf8mb4_unicode_ci是两种不同的字符集,当它们混合使用时就会导致此错误。 解决这个问题的方法是确保在进行比较操作时,两边使用相同的字符集。可以通过在比较操作符两边使用COLLATE关键字来指定相同的字符集。 例如,如果你的查询是这样的:SELECT * FROM table WHERE column1 = 'value',你可以修改为:SELECT * FROM table WHERE column1 COLLATE utf8mb4_general_ci = 'value'。这样就可以避免字符集混合导致的错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [mysql字段编码不一致导致Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_unicode_...](https://blog.csdn.net/chen417980762/article/details/127068037)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_unicode_ci,IMPLICIT) for operat](https://blog.csdn.net/guyue35/article/details/108846249)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [mysql报错Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_unicode_ci,IMPLICIT)](https://blog.csdn.net/summer089089/article/details/109595986)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值