为了账号安全,请及时绑定邮箱和手机立即绑定

SQL Server中,null 与not null 在什么时候用?

SQL Server中,null 与not null 在什么时候用?

呼唤远方 2019-02-06 11:07:52
SQL Server中,null 与not null 在什么时候用?
查看完整描述

2 回答

?
紫衣仙女

TA贡献1839条经验 获得超15个赞

sql server 中使用 null 和 not null 来判断列的空值。

语法为:
列名 is null (字段为空返回true ,不为空返回 false)
列名 is not null (字段为空返回false,不为空返回 true)

例:
select case when a is null then 1 else 0 end from aaa

语法大意:如果a列 为空显示1,不为空显示0

查看完整回答
反对 回复 2019-03-01
?
红颜莎娜

TA贡献1842条经验 获得超12个赞

1.在定义表时
create table t1
(
id int not null , --默认为可以为空
.......
)
2.在筛选字段时,比如你定义邮箱验证表时把没有验证邮箱的用户Email_In的值为空,你要查询没有验证邮箱的用户。要用到的 is null
select * from table where Email_In is null 反之(is not null)为验证过的用户。
可能也不全面,希望可以帮到你。


查看完整回答
反对 回复 2019-03-01
  • 2 回答
  • 0 关注
  • 1445 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信