Null values comparison in where clause
RajendraFeb 25 2012 — edited Feb 26 2012Hi Team,
I want to select data from table based on some where condition.
The problem is the data which i have to compare in the where clause is either null or having some value.
The data is unknown so i can't use 'is null' because if the data is not null then i have to use '=' operator.
Please suggest some way to handle this situation , below example make it more clear to you the situation.
I want to retirve data which matches the value present in the variables value1,value2,value3.
Table Name:- DEMO(A,B,C)
A B C
1 2 null
3 null 5
6 7 8
select A,B,C from demo where A=value1 and B=value2 and c=value3;
value1,value2,value3 are variable which having some which can be null also.
if the value1 or value2 or value 3 having null than the above query doesn't work because for comparing null values i have to use is null.
Please suggest me the right query or procedure to deal with the current scenario.