Using LIKE in an Oracle IN clause

前端 未结 9 1570
情深已故
情深已故 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:29

    No, you cannot do this. The values in the IN clause must be exact matches. You could modify the select thusly:

    SELECT *
      FROM tbl
     WHERE my_col LIKE %val1%
        OR my_col LIKE %val2%
        OR my_col LIKE %val3%
     ...
    

    If the val1, val2, val3... are similar enough, you might be able to use regular expressions in the REGEXP_LIKE operator.

提交回复
热议问题