题解 | 用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
但应该不止这一两种方法,对于不同场景有不同的方法
