题解 | 用where过滤空值练习

用where过滤空值练习

https://www.nowcoder.com/practice/08c9846a423540319eea4be44e339e35

# 第一种方法:在一些SQL方言中,可以使用<>操作符,但会忽略null,因为NULL表示未知值,导致<>无法正确识别NULL状态
select
    device_id,
    gender,
    age,
    university
from
    user_profile
where
    age <> ""
# 第二种方法:这也是最直接的方法,用于检查列或表达式的值是否不为NULL
select
    device_id,
    gender,
    age,
    university
from
    user_profile
where
    age is not null

但应该不止这一两种方法,对于不同场景有不同的方法

全部评论

相关推荐

27届学院本誓死冲击...:自我评价和校园经历全删了,荣誉经历只留奖学金,项目也全得换都不如外卖
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务