Quote:
Originally Posted by db2girl
I'd like to understand the reason why someone would use count(0) or count(some number) in the query.
|
i think the main reason is to make you think
the COUNT() function
counts, right?
and the main characteristic of how this function works is that it ignores NULL, yes?
so COUNT(0) and COUNT(1) and COUNT(937) will all return the exact same results for any given query, and the answer that they will return is exactly the number of rows that the query produces
the number of rows that the query produces, of course, depends entirely on which table(s) are involved, and whether there are any WHERE conditions
now see if you can apply this to your sample queries which return 1
