Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Null values comparison in where clause

RajendraFeb 25 2012 — edited Feb 26 2012
Hi 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.
This post has been answered by Frank Kulash on Feb 25 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 25 2012
Added on Feb 25 2012
8 comments
30,394 views