- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
似乎是 MySQL 的 Bug;要求:
SELECT *
FROM table
WHERE (
id LIKE '%тест 199%'
OR `user` LIKE '%тест 199%'
OR `user_datetime` LIKE '%тест 199%'
OR `user_comments` LIKE '%тест 199%' )
ORDER BY id desc
LIMIT 0, 10
[Err] 1271 - 操作“like”的排序规则混合非法
当我们使用拉丁语时。要求:
SELECT *
FROM table
WHERE (
id LIKE '%test 199%'
OR `user` LIKE '%test 199%'
OR `user_datetime` LIKE '%test 199%'
OR `user_comments` LIKE '%test 199%' )
ORDER BY id desc
LIMIT 0, 10
请求成功;
如何处理?
我所有的请求都是自动生成的,我不能改变逻辑因为函数生成器有很多依赖。
设置:
SET NAMES utf8
Character set utf8 -- UTF-8 Unicode
Collation utf8_general_ci
@eggyal 的UPD
Request:
SHOW CREATE TABLE `comments`
Response:
CREATE TABLE `comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user` varchar(255) NOT NULL DEFAULT '',
`user_datetime` timestamp NULL DEFAULT NULL,
`user_comments` varchar(128) DEFAULT NULL,
UNIQUE KEY `id` (`id`) USING BTREE,
KEY `user_comments` (`user_comments`),
) ENGINE=InnoDB AUTO_INCREMENT=128456 DEFAULT CHARSET=utf8
MySQL 版本 5.5.10
最佳答案
您使用的是什么版本的 MySQL?如 the manual 中所述:
As of MySQL 5.5.3, implicit conversion of a numeric or temporal value to string produces a value that has a character set and collation determined by the
character_set_connection
andcollation_connection
system variables. (These variables commonly are set withSET NAMES
. For information about connection character sets, see Section 10.1.4, “Connection Character Sets and Collations”.)This change means that such a conversion results in a character (nonbinary) string (a
CHAR
,VARCHAR
, orLONGTEXT
value), except when the connection character set is set tobinary
. In that case, the conversion result is a binary string (aBINARY
,VARBINARY
, orLONGBLOB
value).Before MySQL 5.5.3, an implicit conversion always produced a binary string, regardless of the connection character set. Such implicit conversions to string typically occur for functions that are passed numeric or temporal values when string values are more usual, and thus could have effects beyond the type of the converted value.
因此,当使用 LIKE
运算符时,将 TIMESTAMP
列隐式转换为字符串将始终导致字符串binary
字符集,如果您使用的 MySQL 版本早于 5.5.3,则不考虑 SET NAMES
(奇怪的是,sqlfiddle 也是如此,它声称是 5.5。 20);由于此类字符串无法与 utf8
字符集中的字符串进行比较,因此您必须将 user_datetime
列显式转换为 UTF-8 字符串:
SELECT *
FROM `comments`
WHERE (
`id` LIKE '%тест 199%'
OR `user` LIKE '%тест 199%'
OR CONVERT(`user_datetime` USING utf8) LIKE '%тест 199%'
OR `user_comments` LIKE '%тест 199%'
)
ORDER BY `id` DESC
LIMIT 0, 10
关于mysql - 运算符喜欢,字段类型时间戳和西里尔字母? MySQL错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10379299/
我在数据库中有一个具有俄罗斯值(value)观的项目。我需要做的就是附和他们,但事实证明这比预期的要困难。所有俄语字符都只是作为问号打印。 IE: ??? ? ????????对于我尝试过的每种编码,
这是我解析 JSON 的函数: func jsonParsingWeather(urlPath:String) -> NSDictionary { var utf8URLPath = urlP
我是一名优秀的程序员,十分优秀!