zoukankan      html  css  js  c++  java
  • 报错:illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='

    sql语句:

    select t1.block_info, t2.zone 
    from device_indoor_tbl t1 
    left join blackwhitezone_tbl t2 on t1.block_info=t2.zone 

    字符集编码不同:

    报错信息:illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='

    原因:字符集编码不同。

    ps:按理说同一个数据库的字符集编码应该是一样的,奈何之前不知道什么原因数据库竟然有不同的编码,接手的时候数据库又不敢乱改,只能从sql语句着手想办法,百度了好久,最后还是问另外一个同事才解决的。

    解决方法:将两个字段的字符集编码改成相同的。(建议修改成多数表所用的字符集编码,我的数据库多数表是utf8_general_ci编码,只有少数几张例外是utf8_unicode_ci)

    修改后的sql语句:

    select t1.block_info, t2.zone 
    from device_indoor_tbl t1 
    left join blackwhitezone_tbl t2 on t1.block_info=t2.zone COLLATE utf8_general_ci
  • 相关阅读:
    实验七---类的多态
    实验六
    实验五---排序、质数
    实验四---杨辉三角
    node中间件KOA函数
    java文件名判断练习
    npm install 安装报错错误问题
    bundle is not defined 手动搭建项目架构(一)
    ztree实现拖拽功能
    js单线程 详解 来自知乎
  • 原文地址:https://www.cnblogs.com/zminmin/p/7699663.html
Copyright © 2011-2022 走看看