简体   繁体   English

加入另一列中包含一列的位置

[英]Join where one column is contained in another

i have a scenario where i need to join two tables on a condition which states if one column is part of other column, for example: if Table A column column1 is 'ABC' and Table B column column2 is '123ABC456', i have to check whether column1 is a part of column2 if yes there are matched otherwise no. 我有一个场景,我需要在一个条件下连接两个表,如果一列是其他列的一部分,例如:如果表A列column1是'ABC'而表B列column2是'123ABC456',我必须检查column1是否是column2的一部分,如果是,则匹配,否则为no。 I am trying to use "contains" but not able to figure it out how to use it. 我试图使用“包含”,但无法弄清楚如何使用它。 Can anyone please help me. 谁能帮帮我吗。

select B.Column2 from Table B join Table A on A.Id = B.Id 
  and Contains(B.column2,A.column1)

CONTAINS is from Full-Text Search and unlikely to help this scenario. CONTAINS来自全文搜索,不太可能帮助这种情况。

SELECT ...
FROM dbo.TableA
INNER JOIN dbo.TableB
ON TableA.Id = TableB.Id
AND TableB.Column2 LIKE '%' + TableA.Column1 + '%';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM