gpt4 book ai didi

当所有内容都相同时,MySQL 非法混合排序规则

转载 作者:行者123 更新时间:2023-11-29 01:43:46 25 4
gpt4 key购买 nike

我可以在 MySQL 中运行这个查询,它工作得很好。但是,我需要在 ctd.FULL_DESCRIPTION(TEXT 数据类型)上执行一个 LEFT 函数,只取前 3600 个字符,当我尝试这样做时(使用 LEFT(ctd.FULL_DESCIPTION, 3600)),我得到错误:非法混合排序规则 (utf8_general_ci,IMPLICIT) 和 (latin1_swedish_ci,COERCIBLE) 操作 'UNION'

我在这个错误中可以找到的所有内容都表明我的一个专栏与其他专栏的整理方式不同。我对该查询中的所有表执行了 SHOW FULL COLUMNS,所有整理的内容都使用 utf8_general_ci。数据库默认的排序规则也是utf8。我无法在任何地方找到 latin1_swedish_ci 的来源。我错过了什么?

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 允许查询成功运行。

关于当所有内容都相同时,MySQL 非法混合排序规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12711756/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com