[求助]SQL中count()如何使用啊
在SQL中计算count 如何使用,请指教count()后的“()”里的填的数据是什么概念?
计数的,比如select count(ID) from table where ID<>1 就是选出ID列不等于1的行数
[此贴子已经被作者于2007-3-1 17:32:16编辑过]
count(*) 选出数据表的行数,select count(ID) from table where ID<>1这样的话,如果id是null,也会忽略
不是啊,count(*)选出的记录是大于或等于count(id),你去做个实验
create table shiyan(id int,name varchar(10))
insert into shiyan select 1,'a'
insert into shiyan(name) select 'b'
select count(*) from shiyan
select count(id) from shiyan
第一个返回的是2,第二个返回的是1,因为id有一行是null