It seems that you don't know what the NULL values are :) Yes, in the case when the column value is declared as NOT NULL, COUNT(value) is equivalent to COUNT(*).
But look at the example:
CREATE TEMPORARY TABLE testnull0 (
id INT NOT NULL auto_increment,
value VARCHAR(100),
PRIMARY KEY(id)
)
ENGINE=MyISAM;
INSERT INTO testnull0 (id, value) VALUES (1, 'hello'), (2, 'googbye'),
+ (3, NULL);
SELECT COUNT(id), COUNT(value), COUNT(*) FROM testnull0;
Being processed by MySQL (you must specify your DB name, of course), it prints:
+-----------+--------------+----------+
| COUNT(id) | COUNT(value) | COUNT(*) |
+-----------+--------------+----------+
| 3 | 2 | 3 |
+-----------+--------------+----------+
Got the idea? You cannot rely on the suggestion that the value column is declared as NOT NULL, if you did not create the table yorself :) while COUNT(*) always works as expected.
It's REALLY off-topic here, but i think that answering an OT question wrong is worse than answering it right—and even worse than not answering it at all.
|