問題描述
我是 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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!