不等于 <>查询排除 NULL 值 [英] Not equal <> query excludes NULL values

查看:67
本文介绍了不等于 <>查询排除 NULL 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一些我无法弄清楚的 SQL 查询问题.

I'm having a problem with some SQL queries that I cant figure out.

SELECT * FROM MasterList WHERE Requested <> "Yes";

如果我在我的表上运行上述查询,我​​会返回 60 条记录.但是应该接近 300.我认为问题是,某些记录在 Requested 字段中是空白的,而其他记录是 NULL.但我会认为 NULL 仍然算作不等于是",不是吗?如果没有,有没有办法解决这个问题,而不必返回并清空"所有空字段?

If I run the above query on my table I get 60 records returned. However There should be close to 300. I think the issue is, some of the records are just blank in the Requested field and others are NULL. But I would have thought NULL would still count as not equal to "Yes" wouldnt it? If not, is there a way around that without having to go back and 'blank' all the null fields?

推荐答案

Nulls 不计算在比较中,如果你想返回 null 值那么你需要执行以下查询:

Nulls are not counted in comparison, if you want null values to be returned then you need to execute the following query:

SELECT * FROM MasterList WHERE Requested <> "Yes" OR Requested IS NULL;

这篇关于不等于 &lt;&gt;查询排除 NULL 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆