select * from tableA a where exists (select 1 from tableB b where a.id like '%' + b.id + '%');
select * from tableA a join tableB b on a.id like '%' + b.id + '%';