MySQL 中数值比较的Bug?
mysql> select * from topic;
+----+---------------------+-------+-------------+
| id | creatDate | title | category_id |
+----+---------------------+-------+-------------+
| 1 | 2011-12-08 11:03:32 | t0 | 1 |
| 2 | 2011-12-08 11:03:32 | t1 | 1 |
| 3 | 2011-12-08 11:03:32 | t2 | 1 |
| 4 | 2011-12-08 11:03:32 | t3 | 1 |
| 5 | 2011-12-08 11:03:32 | t4 | 1 |
| 6 | 2011-12-08 11:03:32 | t5 | 1 |
| 7 | 2011-12-08 11:03:32 | t6 | 1 |
| 8 | 2011-12-08 11:03:32 | t7 | 1 |
| 9 | 2011-12-08 11:03:32 | t8 | 1 |
| 10 | 2011-12-08 11:03:32 | t9 | 1 |
+----+---------------------+-------+-------------+
mysql> select * from topic where id >= 5.5;
+----+---------------------+-------+-------------+
| id | creatDate | title | category_id |
+----+---------------------+-------+-------------+
| 7 | 2011-12-08 11:03:32 | t6 | 1 |
| 8 | 2011-12-08 11:03:32 | t7 | 1 |
| 9 | 2011-12-08 11:03:32 | t8 | 1 |
| 10 | 2011-12-08 11:03:32 | t9 | 1 |
+----+---------------------+-------+-------------+
为什么没有id为6的记录?
在Oracle中就没有这样的问题问题。
如果有这样的BUG的话.
select * from topic where id >= (select avg(id) from topic);
就肯定不行。相当于不能用avg()函数了。
有人遇见过吗?
[解决办法]
mysql> select * from dept;
+--------+--------+------+
| deptno | dname | loc |
+--------+--------+------+
| 1 | 销售部 | 北京 |
| 2 | 开发部 | 上海 |
| 3 | 人事部 | 杭州 |
| 4 | 行政部 | 郑州 |
| 5 | 销售部 | 上海 |
+--------+--------+------+
5 rows in set (0.00 sec)
mysql> select * from dept where deptno >=3.5;
+--------+--------+------+
| deptno | dname | loc |
+--------+--------+------+
| 4 | 行政部 | 郑州 |
| 5 | 销售部 | 上海 |
+--------+--------+------+
2 rows in set (0.00 sec)
测试正常啊
你的ID什么类型 char ?
[解决办法]
我这边的primary key 就没出现这问题。我用的MySQL
[解决办法]
version: 5.0.67
没这个问题
不管主键还是非主键。都对