問題:
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