MySQLiQuery_异常';带有消息';非法混合排序规则(拉丁文1_瑞典语ci,隐式)和(utf8_通用ci,强制)-与PHP5
我有一个错误:MySQLiQuery_异常';带有消息';非法混合排序规则(拉丁文1_瑞典语ci,隐式)和(utf8_通用ci,强制)-与PHP5,php,mysql,utf-8,collation,Php,Mysql,Utf 8,Collation,我有一个错误: 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 'shiptost
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\u general\u ci
和utf8
。我猜这与查询Františka Křížka有关,因为其他查询也可以。服务器排序规则过去是拉丁语\u瑞典语\u ci
,但我想我现在已经成功地改变了这一切(从上面的表中可以看到)。提前感谢。您能否在问题后面附加以下“shiptoaddress”和“shiptozip”列的排序规则:
根据您提供的证据,“shiptoaddress”列仍然使用拉丁1编码。设置表的编码/排序规则时,您正在设置默认值。可以为单个列覆盖此默认值
如果查询适用于
where address='Frank'
,但不适用于where address='Františka'
,那是因为“Františka”不能转换为拉丁文1。是的,所有字段仍然是拉丁文1。我将了解如何为所有字段更改它。谢谢最后一个注释:查询altertableaddresses转换为字符集utf8代码>将所有列转换为表默认值。
SHOW FULL COLUMNS FROM addresses;