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
  • 相关阅读:
    MySQL主从复制的作用?
    MySQL的逻辑架构
    SQL语句的执行流程
    Count(*)在不同引擎的实现方式
    视图
    MySQL经典练习题(五)
    pyinstaller基本操作
    git基本操作
    Ubuntu安装tensorflow
    ScrollView can host only one direct child
  • 原文地址:https://www.cnblogs.com/zminmin/p/7699663.html
Copyright © 2011-2022 走看看