char型字段的统计 ?
create table t2 (id char(6));插入1 ... 10000条记录。
然后统计:
select count(*) from t2 where id between "5000" and "8000";
select count(*) from t2 where id between 5000 and 8000
----------------------- test@online ---------- Press CTRL-W for Help --------
(count(*))
3334
(count(*))
3001
这个结果怎么来的? create table t2 (id char(6));
插入1 ... 10000条记录。
然后统计:
select count(*) from t2 where id...
sqlnet 发表于 2010-03-06 21:27 http://bbs3.chinaunix.net/images/common/back.gif
一个是字符,一个是数字....数据库在操作时 5000 and 8000 自动是转成integer, "5000" and "8000" 是char型,char型的比较是首字符开始的,因此符合要求的包含"5","6","7","8","50","51"......"80",...."5000",....."8000"
页:
[1]