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