dbTalk Databases Forums  

NOT LIKE excludes NULLS

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss NOT LIKE excludes NULLS in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Randy Harris
 
Posts: n/a

Default NOT LIKE excludes NULLS - 02-16-2005 , 06:26 PM






I'm doing a query, using NOT LIKE, but not getting the results I would like.

WHERE myfile NOT LIKE 'VAR%'

I would like for it to return ALL records that don't begin with VAR, but it
excludes records with a NULL value. I'm really hoping that there is a
simple work around that does not involve adding an OR clause. The
application that creates the query makes it really tough to add ORs.

It will do

( clause and clause) or (clause and clause)

but won't do

clause and (clause or clause)

and there are a bunch of clauses.

Any suggestions would be appreciated.

--
Randy Harris
(tech at promail dot com)



Reply With Quote
  #2  
Old   
Rauf Sarwar
 
Posts: n/a

Default Re: NOT LIKE excludes NULLS - 02-16-2005 , 06:56 PM







Randy Harris wrote:
Quote:
I'm doing a query, using NOT LIKE, but not getting the results I
would like.

WHERE myfile NOT LIKE 'VAR%'

I would like for it to return ALL records that don't begin with VAR,
but it
excludes records with a NULL value. I'm really hoping that there is
a
simple work around that does not involve adding an OR clause. The
application that creates the query makes it really tough to add ORs.

It will do

( clause and clause) or (clause and clause)

but won't do

clause and (clause or clause)

and there are a bunch of clauses.

Any suggestions would be appreciated.

--
Randy Harris
(tech at promail dot com)
NULL is special because you cannot equate it to another value like you
have done. That is why NULL is either IS NULL or IS NOT NULL.
Fortunately in Oracle, NVL gives you the power to assign a temporary
value to NULL so that you can use it in =, != etc operators. Try,

WHERE NVL(myfile, 'FOO') NOT LIKE 'VAR%'

Regards
/Rauf



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.