views:

232

answers:

3

I have a field in a table that is boolean, a range of records have no value (not true or false). How do I write my SQL statement to find these?

I have tried the following SQL statements without success:

1) SELECT * FROM table WHERE field = NULL
2) SELECT * FROM table WHERE field != TRUE AND field != FALSE

Any help would be greatly appreciated.

Many Thanks, Ben

+15  A: 
SELECT * FROM table WHERE field IS NULL
Mitch Wheat
DOH! 17 seconds too slow :)
Nick DeVore
Because it would be easy to miss: use "IS" instead of "=" with NULL. Instead of "!=", similarly, use "IS NOT NULL".
Carl Manaster
+4  A: 

Try

select * from table where field IS null

Nick DeVore
+3  A: 

You want IS NULL I believe:

SELECT * FROM table WHERE field IS NULL
samjudson