Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Null values or Not equal

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2011-10-25 : 12:30:00
I want to select records where a field is null or not equal to 'TOP' or not equal to 'BOTTOM'.

This field can have other values like 'LEFT','RIGHT'....

When I do

select *
from table
where field is null or field <> 'TOP' or field <> 'BOTTOM' It is still returning records where field is equal 'TOP' and 'BOTTOM'

Is there another way I need to be doing this?

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-10-25 : 12:31:05
Try:

select *
from table
where field is null or field NOT IN ('TOP','BOTTOM')
Go to Top of Page
   

- Advertisement -