Using Wildcard with `IN (‘%’)`?

Posted on

Question :

Is it possible to modify the ('%') to return a single row for the following query, i.e. while keeping the entire statement before it?

select 1 FROM DUAL WHERE TRIM('asdfsdf') in ('%')

Answer :

I do not believe it is possible to use the LIKE wildcard in an IN statement. To achieve what you want to do, you need to take out all your LIKE wildcards and put them in a separate OR clause.

WHERE string_col IN ('string1', 'string2')
   OR string_col LIKE '%string3%'
   OR string_col LIKE '%string4%'

But this seems like a REALLY bad idea … I think you should update your post to answer Martin’s question (in the comment) to get a better solution for what you want to do. (or ask a different question)

Leave a Reply

Your email address will not be published. Required fields are marked *