我想使用CONTAINS运算符进行搜索(以选择完全匹配的行),并使用FREETEXT搜索以匹配搜索短语中的单独单词。
主要目标是以完全匹配为首
的方式订购 结果。以下是我尝试的代码示例,但结果得到加倍:
SELECT TOP 100
TreeID AS ObjectID,
PageTitle AS Title,
SUBSTRING(PlainPageContent, 1, 256) AS [Description],
1 AS Priority
FROM TreeTexts
WHERE FREETEXT((PlainPageContent, MenuTitle, PageTitle, WindowTitle), @SearchWord)
AND LanguageID = @LangID
UNION
SELECT TOP 100
TreeID AS ObjectID,
PageTitle AS Title,
SUBSTRING(PlainPageContent, 1, 256) AS [Description],
0 AS Priority
FROM TreeTexts
WHERE CONTAINS((PlainPageContent, MenuTitle, PageTitle, WindowTitle), '"'+@SearchWord+'"')
AND LanguageID = @LangID
ORDER BY Priority
这可能不是我需要的最佳选择命令,所以请你以正确的方式引导我。
谢谢
答案 0 :(得分:0)
您可以从结果中删除重复项。这将是一个很长的问题,但在这里我给了它一个镜头:
Delete T1 From Table1 as T1 INNER JOIN Table1 as T2 ON
T1.Field1=T2.Field1 And T1.ID < T2.ID
其他方法是:
或者您可以从结果集中选择不同的字段。