SqlServer2005 查询 第六讲 null
今天们来讲sql命令中的这个null参数 null null: 可以理解成【没有值,空值】的意思 注意以下几点 --1、零和null是不一样的,null表示空值,而零表示的一个确定的值 --2、null不能参与的运算 <> , != , = --3.null可以参与的运算符是is ,not is 例如 这里所有的操作都是在scott(库)中的emp表做演示 comm 表示的是emp表中的这个奖金字段。 select * from emp where commm <> null; //-- 错误 select * from emp where comm != null; //--错误 select * from emp where comm = null; //-- 错误 select * from emp where comm is null; //--正确,表示的是输出奖金为空的员工的信息 select * from emp where comm not is null; //-- 正确,表示的是输出奖金不为空的员工的信息 4.任何数据类型都允许为null eg: create table test(name nvarchar(20), cnt int, ridi datetime) insert into test values(null,null,null) /