Subject Re: [firebird-support] * vs fieldname
Author Martijn Tonies
> Is there any time where there is an effective difference between:
>
> select count(*) from ...
>
> and
>
> select count(myfieldname) from ...

There's actually a functional difference!

Try this:
CREATE TABLE COUNTED
(
PKCOL INTEGER NOT NULL,
VAL INTEGER,
CONSTRAINT PK_COUNTED PRIMARY KEY (PKCOL)
);

commit;

insert into counted values (1, 1);
insert into counted values (2, NULL);

commit;

select count(val)
from counted

returns 1

while

select count(*)
from counted

returns 2.

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com