In MySql we can count the total number of records by using count(1) or count(*).
Is there any technical difference between them?
MySQL
In MySql we can count the total number of records by using count(1) or count(*).
Is there any technical difference between them?
Best Answer
They are the same. This has often been asked in Stackoverflow and here
all return the count.
In fact, in SQL Server, the expression isn't even evaluated.Edit In fact, in SQL Server, a
COUNT(ALL ...)
CONSTANT expression doesn't appear to be evaluated at all, however, aCOUNT(DISTINCT ...)
is*.e.g.
but
and at least one exception is
NULL
FWR in MySQL
count(1/0)
returns 0 irrespective of the number of rows.