本文介绍了TSQL - 使用全文CONTAINS的联接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有以下select语句,但我希望移至关键字列上的全文搜索。如何重写这个以使用CONTAINS?

I currently have the following select statement, but I wish to move to full text search on the Keywords column. How would I re-write this to use CONTAINS?

SELECT MediaID, 50 AS Weighting
FROM Media m JOIN @words w ON m.Keywords LIKE '%' + w.Word + '%'

@words是一个表格变量,里面填充了我希望查找的单词:

@words is a table variable filled with words I wish to look for:

DECLARE @words TABLE(Word NVARCHAR(512) NOT NULL);


推荐答案

如果CONTAINS允许变量或列, > 可以使用像这样的东西。

If CONTAINS allows a variable or column, you could have used something like this.

SELECT MediaID, 50 AS Weighting
FROM Media m
JOIN @words w ON CONTAINS(m.Keywords, w.word)

但是,根据SQL Server的联机丛书,它不被支持。因此,没有办法做到这一点。

However, according to Books Online for SQL Server CONTAINS, it is not supported. Therefore, no there is no way to do it.

参考:( column_name只出现在CONTAINS的第一个参数中)

Ref: (column_name appears only in the first param to CONTAINS)

CONTAINS
( { column_name | ( column_list ) | * }
  ,'<contains_search_condition>'
[ , LANGUAGE language_term ]
)

这篇关于TSQL - 使用全文CONTAINS的联接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 13:34