Search code examples
databaseoracleentity-relationship

How to fuzzy query a list?


SELECT *

FROM table

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

This will be error with : SQL Error [936] [42000]: ORA-00936: missing expression

How to implement this kind of fuzzy query?


Solution

  • Of course as commented the usage of OR is the correct way, though a bit verbose.

    The most close option to your approach is the usage of regexp_like with a pattern allowing more alternatives.

    Example

    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.,..