> 1267 - Illegal mix of collations (utf16_general_ci,IMPLICIT) and (utf8_bin,IMPLICIT) for operation '='
时间: 2023-10-17 12:25:09 浏览: 190
报错信息 "1267 - Illegal mix of collations (utf16_general_ci,IMPLICIT) and (utf8_bin,IMPLICIT) for operation '=' " 意味着在进行 "=" 操作时,出现了编码(collation)不匹配的错误。更具体地说,utf16_general_ci 和 utf8_bin 这两种编码不兼容,无法进行等值比较。
解决这个问题的方法有两种:
1. 修改表结构:将涉及到的所有表的编码修改为相同的编码(utf16_general_ci 或 utf8_bin)。这样就能保证编码的一致性,避免出现不匹配的情况。
2. 使用 CONVERT 函数:在进行等值比较的时候,使用 CONVERT 函数将编码不匹配的字段进行转换,使它们的编码一致。例如,可以使用以下语句解决该问题:
SELECT * FROM table_name WHERE CONVERT(column_name USING utf8_bin) = CONVERT('value' USING utf8_bin);
这个语句中,将 column_name 的编码转换为 utf8_bin,并将 'value' 也转换为 utf8_bin,然后再进行等值比较。
综上所述,要解决 "1267 - Illegal mix of collations (utf16_general_ci,IMPLICIT) and (utf8_bin,IMPLICIT) for operation '=' " 的报错,可以通过修改表结构或使用 CONVERT 函数来处理编码不匹配的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Illegal mix of collations (utf8_unicode_ci,IMPLICIT)and (utf8_general_ci,IMPLICIT) for operation ‘=...](https://blog.csdn.net/csdn_avatar_2019/article/details/124248524)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [1267 - Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for opera](https://blog.csdn.net/ts3211/article/details/104780081)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文