dbTalk Databases Forums  

LIKE clause

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


Discuss LIKE clause in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Robert Scheer
 
Posts: n/a

Default LIKE clause - 07-17-2006 , 04:27 PM






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


Reply With Quote
  #2  
Old   
Robbert van der Hoorn
 
Posts: n/a

Default Re: LIKE clause - 07-17-2006 , 04:28 PM







"Robert Scheer" <rbscheer (AT) my-deja (DOT) com> wrote

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




Reply With Quote
  #3  
Old   
G Quesnel
 
Posts: n/a

Default Re: LIKE clause - 07-18-2006 , 06:54 AM



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.


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.