SQL包含问题 [英] SQL Contains Question
问题描述
查询:
select * from tbl where contains([name],'* he *AND* ca *')
结果集:
$ b
Hertz租车
Hemingyway的小酒馆
查询:
select * from tbl where contains([姓名],'*他*AND* ar *')
结果 第一个查询是我期望的,但是我希望第二个查询返回Hertz Car Rental。我从根本上误解了'*'是如何在全文搜索中起作用的? 谢谢! 我认为SQL Server正在将您的字符串解释为prefix_terms。星号不是普通的旧通配符说明符。全文和包含是面向字的。对于你正在尝试做的事情,你最好使用普通的旧LIKE而不是CONTAINS。 http://msdn.microsoft.com/en-us/library/ms187787.aspx Can someone explain this to me? I have two queries below with their results. query: result-set: Hertz Car Rental Hemingyway's Cantina
query: result-set: nothing
The first query is what I would expect, however I would expect the second query to return "Hertz Car Rental". Am I fundamentally misunderstanding how '*' works in full-text searching? Thanks! I think SQL Server is interpreting your strings as prefix_terms. The asterisk is not a plain old wildcard specifier. Fulltext and Contains are word oriented. For what you are trying to do, you would be better off using plain old LIKE instead of CONTAINS. http://msdn.microsoft.com/en-us/library/ms187787.aspx 这篇关于SQL包含问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
select * from tbl where contains([name], '"*he*" AND "*ca*"')
select * from tbl where contains([name], '"*he*" AND "*ar*"')