niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Oracle
NOT LIKE excludes NULLS
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
Rauf Sarwar
*nix forums Guru


Joined: 03 May 2005
Posts: 353

PostPosted: Wed Feb 16, 2005 11:56 pm    Post subject: Re: NOT LIKE excludes NULLS Reply with quote

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
Back to top
Randy Harris
*nix forums Guru Wannabe


Joined: 23 Apr 2005
Posts: 202

PostPosted: Wed Feb 16, 2005 11:26 pm    Post subject: NOT LIKE excludes NULLS Reply with 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)
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 2:18 am | All times are GMT
navigation Forum index » Databases » Oracle
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Null and Void() - Or, Abandon All Hope Ye Who allow NULLs? dananrg@yahoo.com PostgreSQL 16 Wed Jun 28, 2006 9:31 am
No new posts SED: Global replacement of pattern containing nulls (x0) nobrow@gmail.com shell 6 Tue Jun 27, 2006 6:50 pm
No new posts unique constraint and nulls Chris Seidel Server 4 Thu May 25, 2006 9:44 pm
No new posts IGNORE NULLS possible fro CREATE INDEX? DB2 UDB v8.1.9 Linux Bob Stearns IBM DB2 3 Wed Apr 12, 2006 4:49 pm
No new posts NULLs are now always NULLs ? Syltrem Server 4 Wed Mar 22, 2006 3:27 pm

Credit Counseling | Free Ringtones | Bankruptcy | Bankruptcy Certification | Keeping Aquarium Fish
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1365s ][ Queries: 20 (0.0648s) ][ GZIP on - Debug on ]