SQL 中是否有“LIKE”和“IN”的组合? - Is there a combination of “LIKE” and “IN” in SQL?

问题:

In SQL I (sadly) often have to use " LIKE " conditions due to databases that violate nearly every rule of normalization.在 SQL 中,我(遗憾的是)经常不得不使用“ LIKE ”条件,因为数据库几乎违反了所有规范化规则。 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.此外,我经常使用像WHERE something in (1,1,2,3,5,8,13,21)这样的条件来提高我的 SQL 语句的可读性和灵活性。

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 this:我想要像WHERE something LIKE ('bla%', '%foo%', 'batz%')这样简单的WHERE something LIKE ('bla%', '%foo%', 'batz%')而不是这样:

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

I'm working with SQl Server and Oracle here but I'm interested if this is possible in any RDBMS at all.我在这里使用 SQl Server 和 Oracle,但我很感兴趣,如果这在任何 RDBMS 中都是可能的。


解决方案:

参考一: https://en.stackoom.com/question/CeK4
参考二: https://stackoom.com/question/CeK4
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章