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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章