只返回具有空字段的行? [英] Only return rows that have an empty field?

查看:43
本文介绍了只返回具有空字段的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张表格,其中一个字段可以为空.我试图仅返回此字段为空的这些行.但是我一直在做 WHERE field = "" ... WHERE field = '' ... WHERE field = null 时出错

I have a table where one of the fields can be empty. I'm trying to return only these rows where this field is empty. But I keep getting errors just doing WHERE field = "" ... WHERE field = '' ... WHERE field = null

知道我缺少什么吗?

推荐答案

在 SQL 中,一个完全空的字段被称为 NULL.对于 NULL 搜索,您不使用等于 (=),而是使用特殊运算符 IS NULL:

In SQL, a completely empty field is said to be NULL. For NULL searches you do not use equals (=), but rather the special operator IS NULL:

 SELECT * FROM table WHERE field IS NULL

如果你允许空字符串,Access 允许你没有 NULL 空字段,这是一个坏主意,因为它很难区分 NULL 值和 0 长度的字符串,所以我建议你不要允许它在您的数据库中.

Access allows you to have not NULL empty fields if you allow empty strings, this is a bad idea as it makes it difficult to distinguish visual between a NULL value and a 0-length string, so I suggest you don't permit it in your database.

这篇关于只返回具有空字段的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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