Is there a combination of “LIKE” and “IN” in SQL?

后端 未结 25 1626
灰色年华
灰色年华 2020-11-22 03:08

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 tha

25条回答
  •  情深已故
    2020-11-22 03:53

    Use an inner join instead:

    SELECT ...
    FROM SomeTable
    JOIN
    (SELECT 'bla%' AS Pattern 
    UNION ALL SELECT '%foo%'
    UNION ALL SELECT 'batz%'
    UNION ALL SELECT 'abc'
    ) AS Patterns
    ON SomeTable.SomeColumn LIKE Patterns.Pattern
    

提交回复
热议问题