打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation &#
userphoto

2019.02.18

关注

问题描述:MySQL进行字符串比较时发生错误:

  1. SELECT
  2. a.equ_no,
  3. b.fullCode
  4. FROM
  5. equipment a,
  6. (
  7. SELECT
  8. t.*, getEquTypeFullCode (t.equType_id) AS fullCode
  9. FROM
  10. equ_type t
  11. ) b
  12. WHERE
  13. substring(a.equ_no, 1, 5) = b.fullCode
错误如下:
[Err] 1267 - Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='

解决方法:将比较等式一边进行字符串转换,如改为“CONVERT(b.fullCode USING utf8) COLLATE utf8_unicode_ci
  1. SELECT
  2. a.equ_no,
  3. b.fullCode
  4. FROM
  5. equipment a,
  6. (
  7. SELECT
  8. t.*, getEquTypeFullCode (t.equType_id) AS fullCode
  9. FROM
  10. equ_type t
  11. ) b
  12. WHERE
  13. substring(a.equ_no, 1, 5) = CONVERT(b.fullCode USING utf8) COLLATE utf8_unicode_ci;


      

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【MySQL】java.sql.SQLException: Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and (utf8mb4_g
1267 - Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' | 1267 - Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (Latin,COERCIBL)
[Err]1267
谡怎么读
觇怎么读
UnicodeEncodeError: 'gbk' codec can't encode character: illegal multibyte sequence
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服