美文网首页
【mysql】Illegal mix of collations

【mysql】Illegal mix of collations

作者: Joey_GZ | 来源:发表于2020-06-11 09:43 被阅读0次

    【操作】sql联合查询

    SET @m='1001';
    select t.TRADE_S,t.TRADE_T,d.TRANS_N,d.TRANS_S,d.* 
    from db.t_main t
    left join db.t_item d on t.O_ID = d.O_ID
    where t.O_NO = @m;
    

    【结果】查询报错:
    Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation '='

    【解决】在变量后指定排序类型、字符编码
    COLLATE utf8mb4_unicode_ci

    SET @m='1001';
    select t.TRADE_S,t.TRADE_T,d.TRANS_N,d.TRANS_S,d.* 
    from db.t_main t
    left join db.t_item d on t.O_ID = d.O_ID
    where t.O_NO = @m COLLATE utf8mb4_unicode_ci;
    
    

    相关文章

      网友评论

          本文标题:【mysql】Illegal mix of collations

          本文链接:https://www.haomeiwen.com/subject/bumvtktx.html