分享

Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation &#

 instl 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;


      

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多