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 '='

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

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

报错: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

 

相关文章:

  • 2022-12-23
  • 2022-02-25
  • 2022-12-23
  • 2021-04-17
  • 2021-12-09
  • 2021-10-07
  • 2022-12-23
  • 2021-07-17
猜你喜欢
  • 2021-04-15
  • 2021-11-04
  • 2021-10-16
  • 2021-09-29
  • 2022-12-23
  • 2022-01-18
  • 2022-12-23
相关资源
相似解决方案