user3312649
user3312649

Reputation: 300

SQL LIKE Concerns

I would like to ask if is there a way I can achieve this query:

Select *
from table1 
where table1.column1 like '%' (Select  table2.column1 from table2)

where table2 contains all the values being compared in the like statement.

Is there a way that I can achieve this?

Upvotes: 0

Views: 38

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270301

You can do this with a correlated subquery:

Select t1.*
from table1 t1
where exists (select 1
              from table2 t2
              where t1.column1 like '%' + t2.column1
             );

Upvotes: 3

Related Questions