Why consider everyone empty and not empty?

<?php include('db.php'); $userssitep=mysql_query("SELECT * FROM `DUser` WHERE Did IS NOT NULL",$db) or die(mysql_error()); $usersreviewp = mysql_num_rows($userssitep); echo $usersreviewp; ?> 

UPD Thank you, you need to undergo a rehabilitation course on the lessons of E.Popov

    2 answers 2

    maybe because null is not empty, but null? and you need to try the request

    SELECT * FROM DUser WHERE Did = ";

    but for counting

     SELECT COUNT(1) FROM `DUser` WHERE Did = ''; 
    • @Gorets see answer @Palmervan select count (*) from DUser where trim (ifnull (did, '')); - alexlz

    A.5.3 Problems with NULL

    The concept of NULL values ​​is often misleading for newbies to SQL, who believe that NULL is the same as the empty string "". This is mistake! For example, the following commands are completely different:

     mysql> INSERT INTO my_table (phone) VALUES (NULL); mysql> INSERT INTO my_table (phone) VALUES (""); 

    Both commands insert a value into the phone column, but the first is a NULL value, and the second is an empty string. The meaning of the first can be referred to as номер телефона неизвестен'', смысл второго - that it does not have a telephone.

    Continue to study the documentation ...

    • one
      probably the opposite in the sense - Gorets