如何选择MySQL中没有空记录的数据?
若要选择非空记录,请使用ISNOTNULL属性。让我们首先创建一个表-
mysql> create table DemoTable1792
(
Name varchar(20)
);使用插入命令在表中插入一些记录-
mysql> insert into DemoTable1792 values('John Smith');
mysql> insert into DemoTable1792 values(NULL);
mysql> insert into DemoTable1792 values('David Miller');
mysql> insert into DemoTable1792 values(NULL);使用select语句显示表中的所有记录-
mysql> select * from DemoTable1792;
这将产生以下输出-
+--------------+ | Name | +--------------+ | John Smith | | NULL | | David Miller | | NULL | +--------------+ 4 rows in set (0.00 sec)
以下是查询以选择没有空记录的数据-
mysql> select * from DemoTable1792 where Name IS NOT NULL;
这将产生以下输出-
+--------------+ | Name | +--------------+ | John Smith | | David Miller | +--------------+ 2 rows in set (0.00 sec)
热门推荐
10 班级集体生日祝福语简短
11 婚庆花篮祝福语简短大气
12 亲戚生日红包祝福语简短
13 牛年除夕祝福语简短的
14 学生节祝福语简短大全
15 家长祝福语大全简短内容
16 祖国七十华诞简短祝福语
17 父亲祝福语大全简短语
18 祖国生日祝福语简短英文