Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '= - 起点终站

我们应该感谢相遇,无论结局是喜是悲....
Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '=
  • 首页 > IT技术
  • 作者:起点终站
  • 2018年4月8日 16:32 星期日
  • 浏览:19827
  • 字号:
  • 评论:0
  • 问题描述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(x USING utf8) COLLATE utf8_unicode_ci”,b.fullCode 为你的变量

    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;  



      您阅读这篇文章共花了:  
    本文作者:起点终站      文章标题: Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '=
    本文地址:https://blog.hellozwh.com/?post=364
    版权声明:若无注明,本文皆为“起点终站”原创,转载请保留文章出处。
    • blogger
    返回顶部| 首页| 手气不错| 网站地图| sitemap| 装逼生成器| 站长介绍|

    Copyright © 2016-2019 起点终站 闽ICP备16011094号-1