Home > front end >  How to find NULL and also Value in the same colum with a query
How to find NULL and also Value in the same colum with a query

Time:08-10

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

CodePudding user response:

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)

CodePudding user response:

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

  • Related