Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '=
問題描述:MySQL進行字符串比較時發生錯誤:
?
SELECT
a.equ_no,
b.fullCode
FROM
equipment a,
(
SELECT
t.*, getEquTypeFullCode (t.equType_id) AS fullCode
FROM
equ_type t
) b
WHERE
substring(a.equ_no, 1, 5) = b.fullCode
錯誤如下:
?
[Err] 1267 - Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='
解決方法:將比較等式一邊進行字符串轉換,如改為“CONVERT(b.fullCode USING utf8) COLLATE utf8_unicode_ci”
?
SELECT
a.equ_no,
b.fullCode
FROM
equipment a,
(
SELECT
t.*, getEquTypeFullCode (t.equType_id) AS fullCode
FROM
equ_type t
) b
WHERE
substring(a.equ_no, 1, 5) = CONVERT(b.fullCode USING utf8) COLLATE utf8_unicode_ci;
來源:https://blog.csdn.net/hellostory/article/details/7266447
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '=的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 包粽子的灰水怎么做
- 下一篇: 分布式应用解耦利器rabbitmq