全文检索查询一条字 [英] full text search query a piece of word
本文介绍了全文检索查询一条字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
示例
我想在我的表中搜索'abc'。
我的表格包含以下单词
abcde
eabcd
deabc
我的查询是这样的但我无法得到任何结果
Example
I want to search 'abc' in my table.
My table contains below words
abcde
eabcd
deabc
My query is like that but I can't get any result
create procedure searchFunction @keyword nvarchar(50)
AS
BEGIN
SET @keyword='"*'+@keyword+'*"'
SELECT * FROM table WHERE CONTAINS(words,@keyword)
END
EXEC searchFunction @keyword='abc'
推荐答案
如果您不需要全文搜索扩展功能,请使用Like运算符:
Sql使用'%'作为完整的通配符,而不是'*'。
有关SQL通配符的更多信息,请点击此处:
http://www.w3schools.com/sql/ sql_wildcards.asp [ ^ ]
如果你必须使用全文搜索,那么有一些事情需要注意包含:
如果您想搜索以...开头,请使用CONTAINS('*'+ term)
如果您想搜索对于任何包含然后使用CONTAINS(期限)
更多关于此:
https://msdn.microsoft.com/en-us/library/ms187787.aspx [ ^ ]
If you do not need the full text search extended features then use the Like operator:
Sql uses '%' as a full wildcard, not '*'.
More info on SQL wildcards here:
http://www.w3schools.com/sql/sql_wildcards.asp[^]
If you must use the full text search then there are some things to note about CONTAINS:
If you wish to search "starts with" then use CONTAINS('*'+term)
If you wish to search for any contains then use CONTAINS(term)
https://msdn.microsoft.com/en-us/library/ms187787.aspx[^]
这篇关于全文检索查询一条字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文