我有一个表与一个典型的unsigned int主键id
select * from log_data where id between -129 and -120
Run Code Online (Sandbox Code Playgroud)
看似试图返回表格中的每一行(或至少陷入'发送数据'几个小时)
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE log_data ALL PRIMARY NULL NULL NULL 357114 Using where
Run Code Online (Sandbox Code Playgroud)
据上的文档BETWEEN在https://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between:
这等同于表达式(分钟<= EXPR AND EXPR <=最大值)如果所有参数都是相同的类型
然而,
select * from log_data where -129 <= id and id <= -120
Run Code Online (Sandbox Code Playgroud)
表现得像我期望的那样.
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Run Code Online (Sandbox Code Playgroud)
这是一个错误,还是可以解释这种行为?