postgresql 检查数据库是否为 NULL 布尔值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/981611/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 23:44:01  来源:igfitidea点击:

Checking database for NULL boolean value

sqlpostgresqlnullboolean

提问by Ben Everard

I have a field in a table that is boolean, a range of records have no value (not true or false). How do I write my SQL statement to find these?

我在一个布尔值的表中有一个字段,一系列记录没有值(不是真或假)。我如何编写我的 SQL 语句来找到这些?

I have tried the following SQL statements without success:

我尝试了以下 SQL 语句但没有成功:

1) SELECT * FROM table WHERE field = NULL
2) SELECT * FROM table WHERE field != TRUE AND field != FALSE

Any help would be greatly appreciated.

任何帮助将不胜感激。

Many Thanks, Ben

非常感谢,本

回答by Mitch Wheat

In TSQL, you need to use ISrather than =when comparing with NULL:

在 TSQL 中,您需要使用IS而不是=与 比较时NULL

SELECT * FROM table WHERE field IS NULL

回答by Nick DeVore

Try

尝试

select * from table where field IS null

回答by samjudson

You want IS NULLI believe:

你要IS NULL我相信:

SELECT * FROM table WHERE field IS NULL