Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

select NULL and false but not true in sql

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.

I want to select only NULL or false values. How can i do this?

like image 712
Gautam Menariya Avatar asked Jan 21 '14 19:01

Gautam Menariya


1 Answers

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

The above assumes that the column activated is of an integral or a BIT data type.

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.

like image 162
Sergey Kalinichenko Avatar answered Oct 09 '22 22:10

Sergey Kalinichenko