mysql <=> null 问题


SELECT * FROM cms_user WHERE age=NULL;
Empty set (0.03 sec)

查询表中记录age值为null

 

 

mysql> SELECT * FROM cms_user WHERE age<=>NULL;
+----+----------+----------+-------------+------------+----------+-------+------+
| id | username | password | email       | regTime    | face     | proId | age  |
+----+----------+----------+-------------+------------+----------+-------+------+
| 12 | test1    | test1    |sui@qq.com | 1419811708 | user.jpg |     1 | NULL |
+----+----------+----------+-------------+------------+----------+-------+------+
1 row in set (0.03 sec)

查询表中的 null 值使用 <=>


使用: is null 和 is not null
ELECT * FROM cms_user WHERE age IS NULL;
+----+----------+----------+-------------+------------+----------+-------+------+
| id | username | password | email       | regTime    | face     | proId | age  |
+----+----------+----------+-------------+------------+----------+-------+------+
| 12 | test1    | test1    | user@qq.com | 1419811708 | user.jpg |     1 | NULL |
+----+----------+----------+-------------+------------+----------+-------+------+
1 row in set (0.00 sec)
IS NOT NULL
mysql> SELECT * FROM cms_user WHERE age IS NOT NULL;
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM