Sunday, March 25, 2012

(ObjKommun IN (xxxx%, oooo%))

My question, is it valid to use "IN" as in "LIKE" conserning strings? (Using the "%" operator)
Thx in advance!Hello,

you cant you % in this way (for Oracle). Use SUBSTR(var, start, length)

Hope this helps ?

Greetz

Manfred Peter
(Alligator Company)
http://www.alligatorsql.de|||This is just a short copy of a SP im using in SQL server... now the problem appears if there will be to many parameters involved.. (HUGE query)

My main problem is how to reduce the length of the query..

So, instead of doing it like this..:

AND (((xxxx like 'yyyy%') OR (xxxx like 'zzzz%')))

I was thinking of doing like this..:

xxxx IN ('yyyy%', 'zzzz%')

But when im using the "IN" im not able to use the % (Cause sometimes strings are weird) and no result is shown, but when removing the % i get the satisfying result, not depending on Case sensitivity which is perfect, but still...

And im really really lousy to explain things, hope its ok anyways ;)|||No, IN cannot be used as a substitute for 'like', it will not work. You could try looking at applying a string function on the column side, e.g. WHERE substring( mycolumn, 0, 4) IN ( 'stri', '1234', 'etc.' )|||Okay, thx for the response.

Think I will use "IN" but forget about trying to make it work like "LIKE" :)

Most important is that the length of the query is shortened.

Best wishes from Sweden.|||Thats it :)

Greetings
Manfred Peter
(Alligator Company)
http://www.alligatorsql.com

No comments:

Post a Comment