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

后端 未结 25 1959
灰色年华
灰色年华 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:55

    May be you think the combination like this:

    SELECT  * 
    FROM    table t INNER JOIN
    (
      SELECT * FROM (VALUES('bla'),('foo'),('batz')) AS list(col)
    ) l ON t.column  LIKE '%'+l.Col+'%'
    

    If you have defined full text index for your target table then you may use this alternative:

    SELECT  * 
    FROM    table t
    WHERE CONTAINS(t.column, '"bla*" OR "foo*" OR "batz*"')
    

提交回复
热议问题