空值处理:IS NULL、IS NOT NULL

create table studentff
(

stu_name nvarchar(20),
phone varchar(11)

);

insert into studentff
values
(N'张三','13864668825'),
(N'李四',null), --手机号为空
(N'王五',''),
(N'赵六','13964668858');

select *
from studentff
where phone is null;

select *
from studentff
where phone is not null;

select *
from studentff
where phone =''; --空字符串

——————————————————————————————————————————————————

空值判断禁止使用 =、<>
为空 → IS NULL
不为空 → IS NOT NULL
NULL 和 空字符串 '' 是两回事

posted @ 2026-04-27 12:34  菜鸟的奋斗军  阅读(7)  评论(0)    收藏  举报