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
基础教程推荐
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 在多列上分布任意行 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
