--1.空值(null)处理
--查询籍贯为NULL同学
--如果判断一个字段的的值是不是null,需要使用is关键字, 不能使用=
select * from TbStudent where stuAddress is null
--查询籍贯不是null的所有同学
select * from TbStudent where stuAddress is not null
--注意:not like ,is not
--查询所有同学信息,如果籍贯是null,就用’未知‘替代
--ISNULL(原始数据,代替值)函数
select stuName,stuNumber,ISNULL (sstuAddress,'未知')from TbStudent
--查询所有数学成绩为null的学生
select * from TbStudent where stuMath is null
--查询所有学生的考试成绩,如果为null,则用’缺考‘代替
select stuName,stuNumber,ISNULL(stuMath,'缺考') from TbStudent
--stuMath是int类型,’缺考‘是varchar类型的,所以不允许填充到同一列上
--数据表中任何一列,都只能存储一种数据类型的数
select stuName,stuNumber,stuMath from TbStudent
--SQL里的NULL和c#里的NULL是不一样的
--c#里的NULl:表示一个引用类型的变量,不指向堆上的任何对象
--SQL里的NULL:unknown,不知道。SQL里的任意数据类型的字段,都可以赋值null
--SQL里NULL与任何数据做运算,结果还是null
--查询所有的学生的数学成绩,并且给所有人的学习成绩+10分
select stuName,stuNumber,stuMath+10 as '数学' from TbStudent
--为啥不让用 = null,只能用 is null
--查询所有学生的考试成绩,如果为null,则用’缺考‘代替
select stuName,stuNumber,ISNULL(CAST(stuMath as varchar(4)),'缺考') from TbStudent
--注意:这个ISNULL()函数,不会修改原表中的数据,它只是把查询结果集中的
--显式方式变了变