当所有内容都排序相同时,MySQL非法混合使用排序规则 [英] MySQL illegal mix of collations when everything is collated the same

查看:71
本文介绍了当所有内容都排序相同时,MySQL非法混合使用排序规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在MySQL中运行此查询,并且效果很好.但是,我需要对ctd.FULL_DESCRIPTION(TEXT数据类型)做一个LEFT函数,并只接受前3600个字符,而当我尝试这样做时(使用LEFT(ctd.FULL_DESCIPTION,3600))我得到了错误:非法混合操作'UNION'的归类(utf8_general_ci,IMPLICIT)和(latin1_swedish_ci,COERCIBLE)

I can run this query in MySQL and it works just fine. BUT, I need to do a LEFT function on ctd.FULL_DESCRIPTION (TEXT datatype) and take just the first 3600 characters and when I try to do that (using LEFT(ctd.FULL_DESCIPTION, 3600)) I get the error: illegal mix of collations (utf8_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation 'UNION'

我能找到的所有关于此错误的内容都表明,我的其中一列与其他列不同.我在此查询中的所有表上执行了SHOW FULL COLUMNS,所有整理的内容都使用utf8_general_ci.数据库的默认排序规则也是utf8.我在哪里都找不到latin1_swedish_ci的位置.我想念什么?

Everything I can find on this error suggests that one of my columns is not collated the same as the others. I did a SHOW FULL COLUMNS on all the tables in this query and everything that's collated is using utf8_general_ci. The default collation of the database is also utf8. I can't find where it's getting latin1_swedish_ci anywhere. What am I missing?

SELECT 
CONCAT(''73'',RIGHT(CONCAT(''000000'',cd.CHANGEID),6)) AS CHANGEID, 
LEFT(cd.TITLE,80) AS CHANGETITLE, FROM_UNIXTIME(cd.CREATEDTIME/1000) AS PRJDATE, 
LEFT(sd.NAME,10) AS STATUSNAME, wo.WORKORDERID AS WOID, LEFT(wo.TITLE,80) AS WOTITLE,
LEFT(au.FIRST_NAME,10) as TECHNAME, ctd.FULL_DESCRIPTION AS CHANGEDSC
FROM servicedesk.changedetails cd, servicedesk.incidenttochangemapping itcm, 
servicedesk.workorder wo, servicedesk.stagedefinition sd, servicedesk.workorderstates 
wos, servicedesk.sduser sdu, servicedesk.aaauser au, servicedesk.changetodescription ctd 
WHERE cd.CHANGEID = itcm.CHANGEID and itcm.WORKORDERID = wo.WORKORDERID and
cd.STAGEID = sd.STAGEID and wo.WORKORDERID = wos.WORKORDERID and wos.OWNERID = 
sdu.USERID and sdu.USERID = au.USER_ID and cd.CHANGEID = ctd.CHANGEID and
cd.STAGEID NOT IN (3,2) and cd.CATEGORYID IN 
(301,2701,3601,3602,3605,3606,4201,4202,4501,4502,4801) and wos.REQUESTTYPEID IN 
(301,601)
UNION
SELECT CONCAT(''73'',RIGHT(CONCAT(''000000'',cd.CHANGEID),6)) AS CHANGEID, 
LEFT(cd.TITLE,80) AS CHANGETITLE, FROM_UNIXTIME(cd.CREATEDTIME/1000) AS PRJDATE, 
LEFT(sd.NAME,10) AS STATUSNAME, '''' AS WOID, '''' AS WOTITLE, '''' AS TECHNAME, 
ctd.FULL_DESCRIPTION AS CHANGEDSC
FROM servicedesk.changedetails cd, servicedesk.stagedefinition sd,
servicedesk.changetodescription ctd
WHERE cd.STAGEID = sd.STAGEID and cd.CHANGEID = ctd.CHANGEID and cd.STAGEID NOT 
IN (3,2) and cd.CATEGORYID IN
(301,2701,3601,3602,3605,3606,4201,4202,4501,4502,4801) and NOT EXISTS (
SELECT NULL FROM servicedesk.incidenttochangemapping itcm WHERE cd.CHANGEID = 
itcm.CHANGEID)

推荐答案

问题是系统变量collat​​ion_connection设置为latin1_swedish_ci,其他所有设置为utf8_general_ci.将collat​​ion_connection设置为utf8_general_ci可以使查询成功运行.

The issue was the system variable collation_connection was set to latin1_swedish_ci and everything else was utf8_general_ci. Setting collation_connection to utf8_general_ci allowed the query to run successfully.

这篇关于当所有内容都排序相同时,MySQL非法混合使用排序规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆