How to count NULL values in MySQL?
I want to know how can i find all the values that are NULL in the MySQL database for example I'm trying to display all the users who don't have an average yet. Here is the MySQL code. SELECT COUNT(average) as num FROM users WHERE user_id = '$user_id' AND average IS_NULL SELECT COUNT(*) as num FROM users WHERE user_id = '$user_id' AND average IS NULL A more generic version (that doesn't depend on the where clause and hence limits your overall results): SELECT SUM(CASE WHEN average IS NULL THEN 1 ELSE 0 END) As null_num, SUM(CASE WHEN average IS NOT NULL THEN 1 ELSE 0 END) AS not_null_num FROM