Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5277
  • Last Modified:

Using IN and LIKE Operator together Oracle SQL %

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
brettanderson77
Asked:
brettanderson77
  • 2
1 Solution
 
MilleniumaireCommented:
Have you tried the LIKE operator:

WHERE colname LIKE '%a%' or colname LIKE '%b%'
0
 
brettanderson77Author Commented:
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
 
MilleniumaireCommented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now