Instance
Try the following examples:
[Email protected]# mysql-u root-p password;EnterPassword:*******Mysql> UseRunoob;DatabaseChangedmysql>CREATE TABLE Tcount_tbl- ( -Runoob_author varchar(40)Not NULL, -Runoob_count INT- );QueryOk, 0Rows affected(0.05Sec)Mysql>INSERT into Tcount_tbl- (Runoob_author,Runoob_count)Values(' Mahran ', 20);Mysql>INSERT into Tcount_tbl- (Runoob_author,Runoob_count)Values(' Mahnaz ',Null);Mysql>INSERT into Tcount_tbl- (Runoob_author,Runoob_count)Values(' Jen ',Null);Mysql>INSERT into Tcount_tbl- (Runoob_author,Runoob_count)Values(' Gill ', 20);Mysql>SELECT* FromTcount_tbl;+-----------------+----------------+|Runoob_author|Runoob_count|+-----------------+----------------+|Mahran| 20 ||Mahnaz| NULL | | jen || | gill |20 |+-----------------+----------------+4in set ( 0.00 Sec) mysql>
You can see in the following instance that the = and! = operators are not working:
Mysql> SELECT * from tcount_tbl WHERE runoob_count = NULL; Empty Set (0.00 sec)mysql> SELECT * from tcount_tbl WHERE runoob_count = NULL; Empty Set (0.01 sec)
Instance
If the Runoob_count column in the lookup data table is NULL, you must use is null and is not NULL, as in the following example:
Mysql>SELECT*From Tcount_tbl-WHERE Runoob_count is NULL;+-----------------+----------------+|Runoob_author|Runoob_count|+-----------------+----------------+|Mahnaz|Null|| Jen |Null|+-----------------+----------------+2RowsInch Set (0.00Sec)Mysql>SELECT* FromTcount_tbl-WHERE Runoob_count is not NULL;+-----------------+----------------+|Runoob_author|Runoob_count| +-----------------+----------------+| Mahran |20 || gill |20 |+-----------------+----------------+2in set ( 0.00 Sec)
Special handling of MySQL null values