Akash
Akash

Reputation: 840

Pass NULL and Blank as parameter in SQL Parameter

I have this strange requirement to pass 'NULL' and "" values from database which should be either '=' or 'IN' Operator.

I have written the query but seems like it's not working.

select * from bookDetails where RBN in ("",null);

Thank you

Upvotes: 0

Views: 75

Answers (3)

Primit
Primit

Reputation: 865

we can't use null in IN.

select * from bookDetails where RBN = '' OR RBN IS NULL

Upvotes: 0

Mukesh Prajapat
Mukesh Prajapat

Reputation: 51

Please use below query to get expected results

Select * From bookDetails Where RBN = '' OR RBN IS NULL

Upvotes: 0

Madhur Bhaiya
Madhur Bhaiya

Reputation: 28834

NULL is a special value, and it has to be handled separately using IS NULL operator, and cant be used in the IN operator:

select * from bookDetails 
where RBN = '' 
      OR RBN IS NULL

Upvotes: 2

Related Questions