-2

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

eshirvana
  • 23,227
  • 3
  • 22
  • 38
özgür
  • 3
  • 1
  • welcome to SO, but please edit your question, in current state its quality does not match the guideline, please include Sample data, Expect output, clear logic written in plain text, and [MCVE](https://stackoverflow.com/help/minimal-reproducible-example). also with `sql` tag you should always also tag your DBMS (e.g. Oracle, Sql-server), visit [how-to-ask](https://stackoverflow.com/help/how-to-ask) for more info. – T. Peter Apr 03 '21 at 07:57

2 Answers2

1

you are looking for this:

select * from atable 
join btable
  on acolumn like '%'|| bcolumn || '%'
eshirvana
  • 23,227
  • 3
  • 22
  • 38
1

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.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786