MySQL查询空字段或非空字段(is null和not null)_MySQL
MySQL查询空字段或非空字段(is null和not null)_MySQL 现在我们先来把test表中的一条记录的birth字段设置为空。 mysql> update test set t_birth=null where t_id=1;Query OK, 1 row affected (0.02 sec)Rows matched: 1 Changed: 1 Warnings: 0 OK,执行成功! 下面看看结果: mysql> select * from test;+------+--------+----------------------------------+------------+| t_id | t_name | t_password | t_birth |+------+--------+----------------------------------+------------+| 1 | name1 | 12345678901234567890123456789012 | NULL || 2 | name2 | 12345678901234567890123456789012 | 2013-01-01 |+------+--------+----------------------------------+------------+2 rows in set (0.00 sec) 接下来分别查询一下字段t_birth值为空或不为空的记录: mysql> select * from test where t_birth is null;+------+--------+----------------------------------+---------+| t_id | t_name | t_password | t_birth |+------+--------+----------------------------------+---------+| 1 | name1 | 12345678901234567890123456789012 | NULL |+------+--------+----------------------------------+---------+1 row in set (0.00 sec) mysql> select * from test where t_birth is not null;+------+--------+----------------------------------+------------+| t_id | t_name | t_password | t_birth |+------+--------+----------------------------------+------------+| 2 | name2 | 12345678901234567890123456789012 | 2013-01-01 |+------+--------+----------------------------------+------------+1 row in set (0.00 sec) 说明: 以上就是MySQL查询空字段或非空字段(is null和not null)_MySQL的内容, |