Search code examples
sqloracle-databasesql-likesql-in

Using oracle sql in like together


I`m trying to find results between two different tables. Query is like below

select * from atable 
where acolumn like in (select bcolumn from btable)

Acolumn is like someid_123 and Bcolumn is like someid with these datas i cant use only in statement, i need to use something that can act like "like and in" statements I googled it but couldn't find something like, could you help me? Thank you


Solution

  • You can use exists:

    select a.*
    from atable a
    where exists (select 1
                  from btable b
                  where a.acolumn like b.bcolumn
                 );
    

    You can add wildcards to b.bcolumn if that is also needed, but your question doesn't suggest that is necessary.