I have a sql select like below:
select * from table1 where text in (select text from table2)
In real in in clausule is more complex select that this. text is string (varchar). How to expand that sql to select rows from table1 where text is like texts from table2 (not only exactly equals) ?
If you have your wild card expressions in the text column in Table2 you can do like this.
select *
from Table1 as T1
where exists (select *
from Table2 as T2
where T1.[text] like T2.[text])
Otherwise you need to add the % in your query.
select *
from Table1 as T1
where exists (select *
from Table2 as T2
where T1.[text] like '%'+T2.[text]+'%')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With