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
LIKE clause
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
Author Message
Robert Scheer
*nix forums beginner


Joined: 16 Feb 2006
Posts: 3

PostPosted: Mon Jul 17, 2006 9:27 pm    Post subject: LIKE clause Reply with quote

Hi.

I have a query that uses the Like clause like that (only relevant
code):

....
and fl.status like (case when param1 = 1 then '%NBH%'
when param1 = 2 then '%SVH%'
when param1 = 3 then '%H%' end)
....

In fact, I would like the above SQL to show all records, if my
parameter is 3. I could not find how to do that, so I used a letter
that is common to all my values. Is this the correct way to do that?

Regards,
Robert Scheer
Back to top
Robbert van der Hoorn
*nix forums beginner


Joined: 29 Jun 2006
Posts: 16

PostPosted: Mon Jul 17, 2006 9:28 pm    Post subject: Re: LIKE clause Reply with quote

"Robert Scheer" <rbscheer@my-deja.com> wrote in message
news:1153171657.974800.238020@s13g2000cwa.googlegroups.com...
Quote:
Hi.

I have a query that uses the Like clause like that (only relevant
code):

...
and fl.status like (case when param1 = 1 then '%NBH%'
when param1 = 2 then '%SVH%'
when param1 = 3 then '%H%' end)
...

In fact, I would like the above SQL to show all records, if my
parameter is 3. I could not find how to do that, so I used a letter
that is common to all my values. Is this the correct way to do that?

Regards,
Robert Scheer

Try: like '%'


Robbert
Back to top
G Quesnel
*nix forums addict


Joined: 29 Apr 2005
Posts: 77

PostPosted: Tue Jul 18, 2006 11:54 am    Post subject: Re: LIKE clause Reply with quote

Note that you may get better performance by removing the case
statement. Something like;
and (param1 = 3
or (then param1 = 1 and fl.status like '%NBH%')
or (then param1 = 2 and fl.status like '%SVH%') )

If as you said, you don't need to lookup the value of fl.status when
param1 is 3.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
The time now is Mon Dec 01, 2008 8:56 pm | All times are GMT
navigation Forum index » Databases » Oracle
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts newbie:sql trim() in where clause not working joes Oracle 7 Fri Jul 14, 2006 2:16 pm
No new posts IDs in IN clause Robert Wehofer Oracle 2 Wed Jul 12, 2006 9:16 am
No new posts question regarding OR clause with fietch first 1 row only Roger IBM DB2 8 Wed Jun 21, 2006 9:05 pm
No new posts how to set parallel clause at database level sachin DBA Server 2 Fri Jun 16, 2006 6:42 am
No new posts Aggregate functions not allowed in WHERE clause Ricardo Naranjo Faccini PostgreSQL 4 Tue Jun 13, 2006 2:00 am

Personalized Gifts | Online Advertising | Mortgage Calculator | SMS-Sprüche | Free phpBB forum
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.4708s ][ Queries: 16 (0.3960s) ][ GZIP on - Debug on ]