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
基础教程推荐
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
