如何模糊查询列表?

How to fuzzy query a list?

SELECT *

从table

WHERE column_one LIKE IN ('%one%', '%two%');

这将是错误的:SQL 错误 [936] [42000]: ORA-00936: 缺少表达式

如何实现这种模糊查询?

当然如评论所述OR的用法是正确的方式,虽然有点冗长.

您的 方法最接近的选择是使用 regexp_like 和允许更多选择的模式。

例子

with tab as (
select '...one..' column_one from dual union all
select '.two.,..' column_one from dual union all
select '.three..' column_one from dual)
select *
from tab
where  regexp_like(column_one,'(one|two)'); 

COLUMN_O
--------
...one..
.two.,..

您可以生成查找 table 并使用 exists 谓词检查每个输入行。

create table t as
  select
    level as id
    , decode(mod(level, 7), 1,'A', 'B')
      || dbms_random.string('i', 10) as val
  from dual
  connect by level < 16
with lkp(val) as (
  select *
  from table(sys.odcivarchar2list(
    'A%',
    '%F%'
  ))
)
select *
from t
where exists (
  select 1
  from lkp
  where t.val like lkp.val
)
ID | VAL        
-: | :----------
 1 | AJHCIHZIVQY
 2 | BQCYACBBLFS
 3 | BVATBIEQFEF
 4 | BHEFYAUUENF
 7 | BFPZVWRWTFP
 8 | AGSKVEXPFSV
11 | BFSJXDRGAWV
14 | BFVXCSQWUQT
15 | AFJPPPHDTKM

db<>fiddle here