[英]SQL Full Text Search Problem
What am I doing wrong with my full text search? 我的全文搜索出现什么问题? If this code
如果此代码
Select UserID, UserName
From Users
Where Contains([UserName], '%Jack%')
I get the user jack back, but if I do this 我将用户插孔重新找回,但如果这样做
Select UserID, UserName
From Users
Where Contains([UserName], '%Ja%')
I get nothing what am I doing wrong? 我什么都没做,我做错了什么?
You're mixing LIKE syntax with CONTAINS. 您正在将LIKE语法与CONTAINS混合使用。 Keep in mind that full text searching is word based, while like searches for a character pattern within a string.
请记住,全文搜索是基于单词的,而类似于在字符串中搜索字符模式。
Try: 尝试:
Select UserID, UserName
From Users
Where Contains([UserName], '"Ja*"')
Contains([UserName], '"Ja*"')
- Syntax for PREFIX search. Contains([UserName], '"Ja*"')
-PREFIX搜索的语法。 Would match "Jack" but NOT "Ajax" 会匹配“杰克”,而不匹配“阿贾克斯”
You cannot do any POSTFIX search with full text search. 您无法使用全文搜索进行任何POSTFIX搜索。 If you were to try:
如果您要尝试:
Contains([UserName], '"*Ja*"') -- wrapped in *
This would actually still do a PREFIX ONLY search, it will strip out all special characters that are not proper syntax, meaning the first * would be stripped then ran. 实际上,这仍然会进行PREFIX ONLY搜索,它将去除所有不正确语法的特殊字符,这意味着将删除第一个*然后运行。 If you need open ended search you need to use %% still to find inner parts or words.
如果您需要开放式搜索,则需要使用%%来查找内部部分或单词。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.