Solved

Using IN and LIKE Operator together Oracle SQL %

Posted on 2008-06-18
3
5,171 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

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Loading flat file data in tables 2 58
Select question from MySQL 1 20
plsql job on oracle 18 72
Oracle SQL Developer - SubString 2 23
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
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…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

713 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