gpt4 book ai didi

MySQL错误: Illegal Mix of Collations

转载 作者:行者123 更新时间:2023-11-29 18:57:38 25 4
gpt4 key购买 nike

我收到以下错误消息

[Err] 1267 - Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='

子查询包含来自两个不同数据库的两个表的并集。我试图执行的查询如下所示

SELECT  c.CORRECTION_NO FROM    (
SELECT "regm2017" as `SESSION`,SERIALNO,NAME,FATHER
FROM regm2017.master r17
WHERE r17.IS_DELETED=0
UNION
SELECT "regm2016" as `SESSION`,SERIALNO,NAME,FATHER
FROM regm2016.master r16
WHERE r16.IS_DELETED=0
) as r JOIN corrections_registration as c ON c.SERIALNO = r.SERIALNO
AND c.`SESSION`= r.`SESSION`;

最佳答案

这是由于排序规则的变化而发生的。如果您在查询中明确给出任何值,排序规则将从连接中获取。

你可以使用这样的东西。

     SELECT c.CORRECTION_NO FROM (
SELECT "regm2017" COLLATE utf8_general_ci as > `SESSION`,SERIALNO,NAME,FATHER
FROM regm2017.master r17
WHERE r17.IS_DELETED=0
UNION
SELECT "regm2016" COLLATE utf8_general_ci as `SESSION`,SERIALNO,NAME,FATHER
FROM regm2016.master r16
WHERE r16.IS_DELETED=0
) as r JOIN corrections_registration as c ON c.SERIALNO =
r.SERIALNO
AND c.`SESSION`= r.`SESSION`;`

或者

  SELECT c.CORRECTION_NO FROM    (
SELECT "regm2017" COLLATE latin1_swedish_ci as `SESSION`,SERIALNO,NAME,FATHER
FROM regm2017.master r17
WHERE r17.IS_DELETED=0
UNION
SELECT "regm2016" COLLATE latin1_swedish_ci as `SESSION`,SERIALNO,NAME,FATHER
FROM regm2016.master r16
WHERE r16.IS_DELETED=0
) as r JOIN corrections_registration as c ON c.SERIALNO = r.SERIALNO
AND c.`SESSION`= r.`SESSION`;

关于MySQL错误: Illegal Mix of Collations,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44061605/

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