【发布时间】:2013-01-09 06:24:50
【问题描述】:
我有一个整理问题。它正在影响该表的 3 列,creation_date、product_id 和 lastmodified。
我已将列更改为 utf8mb4,但他们不接受。请看下文。
CREATE TABLE `users` (
`id` int(32) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`creation_date` datetime DEFAULT NULL,
`product_id` int(32) DEFAULT NULL,
`lastmodified` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=121 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
查询:
select * from users u where u.name like '%philėp%'
No errors, 1 row.
select * from users u where u.creation_date like '%philėp%'
Illegal mix of collations for operation 'like'
MySQL 系统变量:
show variables like '%character_set%';
character_set_client utf8
character_set_connection utf8
character_set_database utf8
character_set_filesystem binary
character_set_results utf8
character_set_server utf8mb4
character_set_system utf8
当我手动强制 MySQL 转换语句中的列时,它确实有效。
select * from users u where CONVERT(u.creation_date USING utf8mb4) like '%philėp%'
No errors; 0 rows;
已经不是utf8mb4格式了吗?
不胜感激。
【问题讨论】:
-
你怎么会有这样的创作日期?
u.creation_date like '%philėp%' -
只是想了解排序规则
标签: mysql sql character-encoding