---
title: "Illegal mix of collations (utf8_general_ci,IMPLICIT) and (gbk_chinese_ci,COERCIB"
author: "streammoon"
date: "2013-10-14T08:51:45Z"
tags: []
categories: ["编程语言"]
slug: "illegal-mix-of-collations-utf8-general-ci-implicit-and-gbk-chinese-ci-coercib"
draft: false
lastmod: "2013-10-14T08:54:46Z"
id: 1956214
url: "https://streammoon.iteye.com/blog/1956214"
---

myeclipse8 + mysql：
其中数据库以及表的编码都是utf-8;

 Illegal mix of collations (utf8_general_ci,IMPLICIT) and (gbk_chinese_ci,COERCIBLE) for operation 'UNION'

这是在使用union关联时出现的问题；

解决如下：
在代码中 查询出来的字段上添加 convert( using utf8）；如：

select '列值'  as 列名 from  table。。。
换成
select convert('列值' using utf8) as 列名   table。。。

如果有子查询的话 是放在最外层的查询结果上。。。