在执行以下SQL语句时

sql = "select reject_id, rejectdate,rejectreason, receivedocdate, receivedoctime from rejectprj where fhbh=(selectfhbh from reviewprj where id=?) order by reject_id desc " ;

出现以下错误:

Illegal mix of collations(latin1_swedish_ci,IMPLICIT) and (gbk_chinese_ci,IMPLICIT) for operation '='错误

 

进入MySQL,分别查看rejectprj和reviewprj两个表的结构,通过show full columns from <table>,查看其Collation,如下图


修改mysql字符集冲突


其中reviewprj的fhbh为gbk_chinese_ci,而rejectprj的fhbh为latin1_swedish_ci,所以当两表通过fhbh关联时,就会出现以上错误。

 

则通过以下命令将rejectprj的fhbh的Collation更改为gbk_chinese_ci。

 

mysql>alter table rejectprj changecolumn fhbh fhbh varchar(20) character set 'gbk_chinese_ci';

 

这样修改后,执行以上SQL命令不会出错了。

相关文章:

  • 2022-01-27
  • 2021-12-08
  • 2021-11-28
  • 2021-07-23
  • 2022-12-23
猜你喜欢
  • 2021-11-28
  • 2021-08-07
  • 2021-09-15
  • 2022-01-05
  • 2021-10-21
  • 2022-01-30
相关资源
相似解决方案