Stored Procedure to query value of one column in First Table to Match any value in Second Table?
I wrote this but it only returns exact matchs such as 'Carburetor' not 'Brand X Carburetor' Any help would be greatly appreciated!
SELECT [Col]
FROM a
WHERE ([Col]) IN
( SELECT [col]
FROM B
)
UNION ALL
SELECT Di开发者_Python百科stinct [col]
FROM B
WHERE ([col]) IN
(
Select [col]
FROM A
)
Using SQL Server, you might try as follow.
SELECT a.[Col]
FROM a
INNER JOIN b ON a.Col LIKE '%' + b.Col + '%'
UNION ALL
SELECT Distinct b.[col]
FROM b
INNER JOIN a ON b.COL LIKE '%' + a.Col + '%'
精彩评论