正確示例
# 等于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)