欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '=

发布时间:2024/9/20 编程问答 44 豆豆
生活随笔 收集整理的这篇文章主要介绍了 Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '= 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

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

 

  • SELECT

  • a.equ_no,

  • b.fullCode

  • FROM

  • equipment a,

  • (

  • SELECT

  • t.*, getEquTypeFullCode (t.equType_id) AS fullCode

  • FROM

  • equ_type t

  • ) b

  • WHERE

  • 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

     

  • SELECT

  • a.equ_no,

  • b.fullCode

  • FROM

  • equipment a,

  • (

  • SELECT

  • t.*, getEquTypeFullCode (t.equType_id) AS fullCode

  • FROM

  • equ_type t

  • ) b

  • WHERE

  • substring(a.equ_no, 1, 5) = CONVERT(b.fullCode USING utf8) COLLATE utf8_unicode_ci;

  • 来源:https://blog.csdn.net/hellostory/article/details/7266447

    与50位技术专家面对面20年技术见证,附赠技术全景图

    总结

    以上是生活随笔为你收集整理的Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '=的全部内容,希望文章能够帮你解决所遇到的问题。

    如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。