SQL空值处理

SQL空值处理

  1. 数据库中,如果一个列没有制定值,那么值就是null,数据库中的null表示“不知道”,而不是表示“没有”,因此select null + 1 ,结果是null,因为“不知道”加1的结果还是“不知道”
  2. SQL中使用is null,is not null来进行空值判断
select * from student where email is null
select * from student where email is  not null
  1. ISNULL()如果发现对应的结果集是null值,则以指定的字符串文本进行替换
select StudentNo,StudentName,ISNULL(Email,'未填写') from student 

版权声明:本文为slb190623原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。