Tal Dayan
Tal Dayan

Reputation: 21

How to find NULL and also Value in the same colum with a query

I am trying to get both the nulls and value = 2 so far I tried IN (2,null) got only the values equals to 2 also AND columName = 2 OR columName IS NULL got only values equals to 2.

columName
2
NULL

Upvotes: 0

Views: 126

Answers (2)

Md. Suman Kabir
Md. Suman Kabir

Reputation: 5453

As the issue is resolved, this is just an alternate solution you may use. You can use ISNULL in your Where clause for what you are looking for. Try this :

select * from yourTable
where isnull(columName, 2) = 2

Check SQL

Upvotes: 1

Dani
Dani

Reputation: 2036

This works:

select * from TABLE
where field ='value' or field is null

I think your problem is here:

AND columName = 2 OR columName IS NULL

Should be:

... AND (columName = 2 OR columName IS NULL)

Upvotes: 1

Related Questions