如何解决Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (gbk_chinese_ci,IMPLICIT)的问题
2015-10-28 14:41
651 查看
在执行以下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,如下图
其中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命令不会出错了。
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,如下图
其中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命令不会出错了。
相关文章推荐
- MySQL中的integer 数据类型
- MySQL存储过程
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv
- source命令执行SQL脚本文件
- MySQL创建用户及权限控制
- MySQL管理数据表
- linux下mysql添加用户
- mysql procedure
- mysql触发器
- MySQL 备份和恢复策略
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- MySQL数据的导出、导入(mysql内部命令:mysqldump、mysql)
- mysql数据行转列
- Linux下修改MySQL编码的方法
- MySQL Server 日志
- MySQL 安全事宜
- MySQL 备份与恢复