Using LIKE in an Oracle IN clause

前端 未结 9 1566
情深已故
情深已故 2020-12-06 09:49

I know I can write a query that will return all rows that contain any number of values in a given column, like so:

Select * from tbl where my_col in (val1, v         


        
9条回答
  •  长情又很酷
    2020-12-06 10:19

    select * from tbl 
    where my_col like '%val1%' or my_col like'%val2%' or my_col like '%val3%', ...
    

    But beware, that might be quite slow... Alternatively, you could insert all acceptable values (including % signs) into a table and semi-join that table:

    select * from tbl
    where exists (select 1 from all_likes where tbl.my_col like all_likes.value)
    

    For true full-text search, you might want to look at Oracle Text:

    http://www.oracle.com/technetwork/database/enterprise-edition/index-098492.html

提交回复
热议问题