Solved

Using IN and LIKE Operator together Oracle SQL %

Posted on 2008-06-18
3
5,124 Views
Last Modified: 2013-12-12
Hi,

I have a text list to use with IN operator - IN ('a','b') yet i need to compare it to a field that might contain the value of a;b so i want to put wild cards in the IN list??? Doesn't seem to work - ie:

WHERE IN ('%a%' ,  '%b%')

Any other way to achieve this without importing text files to table etc?

Cheers,
Brett
0
Comment
Question by:brettanderson77
  • 2
3 Comments
 
LVL 16

Expert Comment

by:Milleniumaire
ID: 21811777
Have you tried the LIKE operator:

WHERE colname LIKE '%a%' or colname LIKE '%b%'
0
 

Author Comment

by:brettanderson77
ID: 21811801
Hi,
Problem is it isn't in a table, its values i've copied into a list (a,b etc) from XL.
Hence why i'm trying to use IN ()
Cheers,
Brett
0
 
LVL 16

Accepted Solution

by:
Milleniumaire earned 500 total points
ID: 21812080
You could try building a stored function which would accept the list as an argument and then loop through each item in the list using a sql statement to "like" the values.  The function could then be called from the WHERE clause of the statement to control which rows are returned.

Not a very elegant or efficient solution though.  I may be missing something that another expert can identify, but I'm not aware of an easy way of doing what you want.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now