Is there a combination of "LIKE" and "IN" in SQL?

Posted by Techpriester on Stack Overflow See other posts from Stack Overflow or by Techpriester
Published on 2010-06-10T13:44:16Z Indexed on 2010/06/10 13:52 UTC
Read the original article Hit count: 192

Filed under:
|
|

Hi folks.

In SQL I (sadly) often have to use "LIKE" conditions due to databases that violate nearly every rule of normalization. I can't change that right now. But that's irrelevant to the question.

Further, I often use conditions like WHERE something in (1,1,2,3,5,8,13,21) for better readability and flexibility of my SQL statements.

Is there any possible way to combine these two things without writing complicated sub-selects?

I want something as easy as WHERE something LIKE ('bla%', '%foo%', 'batz%') instead of

WHERE something LIKE 'bla%'
OR something LIKE '%foo%'
OR something LIKE 'batz%'

I'm working with MS SQl Server and Oracle here but I'm interested if this is possible in any RDBMS at all.

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server