开发者

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 + '%'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜