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
基础教程推荐
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 在 SQL 中连接多个表 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 无法解决整理冲突 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
