select NULL and false but not true in sql(在 sql 中选择 NULL 和 false 但不是 true)
问题描述
我是 vb.ner sql 中的一个新人,我问的可能是愚蠢的问题.我在 sql server 2005 中有一个表,并激活了一个列名.此列包含 NULL、true 或 false.
i an new in vb.ner sql and what i am asking may be silly question. I have a table in sql server 2005 and a column name activated. this column contain NULL, true or false.
我只想选择 NULL 或 false 值.我怎样才能做到这一点?
I want to select only NULL or false values. How can i do this?
推荐答案
选择应该在 SQL Server 一侧完成.您的查询应如下所示:
The selection should be done on the SQL Server's side. Your query should look like this:
SELECT *
FROM MyTable
WHERE activated = 0 OR activated is NULL
以上假设列 activated
是整数或 BIT
数据类型.
The above assumes that the column activated
is of an integral or a BIT
data type.
注意:使用看似等效的 WHERE 激活 <> 可能很诱人.1
条件.但是,这是不正确的,因为将 NULL
值与任何值进行比较会导致 NULL
,因此将排除具有 activated = NULL
的行.
Note: it may be tempting to use a seemingly equivalent WHERE activated <> 1
condition. This would be incorrect, though, because comparisons of NULL
values to anything result in a NULL
, so the rows with activated = NULL
would be excluded.
这篇关于在 sql 中选择 NULL 和 false 但不是 true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 sql 中选择 NULL 和 false 但不是 true


基础教程推荐
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01