MySQL Weirdness

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?

One Response to “MySQL Weirdness”

  1. myfreestyle_08 Says:

    I guess that zero is the false value. There’s an error in your page. You must debug it.

Leave a Reply


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