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

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

    There is no combination of LIKE & IN in SQL, much less in TSQL (SQL Server) or PLSQL (Oracle). Part of the reason for that is because Full Text Search (FTS) is the recommended alternative.

    Both Oracle and SQL Server FTS implementations support the CONTAINS keyword, but the syntax is still slightly different:

    Oracle:

    WHERE CONTAINS(t.something, 'bla OR foo OR batz', 1) > 0
    

    SQL Server:

    WHERE CONTAINS(t.something, '"bla*" OR "foo*" OR "batz*"')
    

    The column you are querying must be full-text indexed.

    Reference:

    • Building Full-Text Search Applications with Oracle Text
    • Understanding SQL Server Full-Text

提交回复
热议问题