報錯信息:
1267-?Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '=
問題描述:
SELECT distinct a.user_id INTO userID FROM authorization_record a WHERE a.open_id = openId AND a.auth_type = '5001';
錯誤如下:
[Err]1267- Illegal mixofcollations (utf8_unicode_ci,IMPLICIT)and(utf8_general_ci,IMPLICIT)foroperation'='
解決方法:
將比較等式一邊進行字符串轉(zhuǎn)換,如改為“CONVERT(b.fullCode USING utf8) COLLATE utf8_unicode_ci”
SELECT distinct a.user_id INTO userID FROM authorization_record a WHERE a.open_id = CONVERT(openId USING utf8) COLLATE utf8_unicode_ci AND a.auth_type = '5001';