Archive for February, 2007

MySQL Weirdness

Tuesday, February 13th, 2007

I ran across some MySQL weirdness today that bugged me.   Basically the counts for the NULL values are being zeroed out. (or not grouped in the first place)   Does anyone out there have an explanation?

mysql> select distinct value, count(value) from my_table group by value;
+---------------+----------------------+
| value          | count(value)        |
+---------------+----------------------+
|          NULL |                    0 |
|             0 |                  121 |
|             1 |                  321 |
+---------------+----------------------+
3 rows in set (0.02 sec)

mysql> select count(1) from my_table
+----------+
| count(1) |
+----------+
|     4202 |
+----------+
1 row in set (0.00 sec)

Clearly there should be 3,760 NULL values reported, no?


<Kered.org>   © Copyright 2000-2005 by Derek Anderson
Get Firefox