当table1.cloumn
的值包含来自table2.column
的值时,我需要从select * from Products1 where sku like '%' + (select sku from Products2) + '%'
中选择
我在尝试这个:
exists
您可以尝试将select *
from Products1 t1
where exists(
select 1
from Products2 t2
WHERE t1.sku like '%' + t2.sku+ '%'
)
与子查询一起使用。
sqlfiddle
INNER JOIN
其他答案的替代方法是使用SELECT P1.*
FROM Products1 P1
INNER JOIN Products2 on P1.sku like '%' + P2.sku+ '%'
select t1.*
from Products1 t1
where t1.sku like '%'+ (
select t2.sku from Products2 t2
)+ '%'