当前位置: 动力学知识库 > 问答 > 编程问答 >

sql server - SQL - join on free text field

问题描述:

I have two tables from two different databases that I want to join together but I don't have a column on which this can be easily done by a join.

In table A I have a table with server names

In table B I have a table where one of the columns has a free text field (description).

I want to be able to create a search that searches for the server name within the description column and then add that description column onto the end of table A.

For example:

Table A Table B

name date

server description

customer

Output

name

server

customer

description (join on searching for server name in description)

网友答案:

If you don't have a full text index on description, then you can use like:

SELECT A.name, A.server, A.customer, B.description
FROM A JOIN
     B
     ON ' ' + B.description + ' ' LIKE '% ' + A.server ' %';
网友答案:
SELECT A.name, A.server, A.customer, B.description
FROM A
JOIN B ON CONTAINS(B.description, A.server)

https://msdn.microsoft.com/en-us/library/ms187787.aspx

分享给朋友:
您可能感兴趣的文章:
随机阅读: