我有这个错误:
Fatal error: Uncaught exception 'MySQLiQuery_Exception' with message 'Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=': select id from 'addresses' where 'shiptozip'='13000' and 'shiptostreet'='Františka Křížka'
如您所见,我正在尝试从表地址中获取ID。
mysql> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
mysql> show variables like 'collation%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
表“地址”所在的位置还具有
utf8_general_ci
和utf8
。我想这与查询FrantiškaKřížka有关,因为其他查询也可以。 server_collation以前是latin_swedish_ci
,但我想现在已经全部更改了(如上表所示)。提前致谢。 最佳答案
您可以在问题中附加以下项的“ shiptoaddress”和“ shiptozip”列的排序规则吗?
SHOW FULL COLUMNS FROM addresses;
根据您提供的证据,可能发生的情况是“ shiptoaddress”列仍具有latin1编码。设置表的编码/排序规则时,您将设置默认值。可以为单个列覆盖此默认值。
如果查询适用于
where address = 'Frank'
但不适用于where address = 'Františka'
,这是因为“Františka”不可转换为latin1。