正确示例
# 等于null
select * from 表名 where 字段名 is NULL;
# 不等于null
select * from 表名 where 字段名 is not NULL;
- 若需要同时判断字段不等于某个值且不为null
select * from users where age != 30 and age is not null;
select * from users where age != 30 or age is not null;
- 为什么不能用
!=
和=
判断呢- NULL 表示缺失值, 字段 = NULL 或 字段 != NULL 始终返回假(False)