Liquid Media's Apps

MySQL can't count

My dislike of MySQL is well know. Here's a gotcha I just found which doesn't seem to appear on the infamous MySQL Gotchas page:

mysql> select count(*) from events where type is null;
+----------+
| count(*) |
+----------+
|       68 | 
+----------+
1 row in set (0.00 sec)

mysql> select type, count(type) from events group by type;
+-----------+-------------+
| type      | count(type) |
+-----------+-------------+
| NULL      |           0 | 
| DayEvent  |         875 | 
| NullEvent |        5501 | 
+-----------+-------------+
3 rows in set (0.01 sec)

Explain, please, how this could possibly make sense in any context??

Tagged .
blog comments powered by Disqus