gpt4 book ai didi

SQL 包含 - 仅在开始时匹配

转载 作者:行者123 更新时间:2023-12-05 08:24:27 28 4
gpt4 key购买 nike

出于某种原因,我无法在 Google 上找到答案!但是使用 SQL contains 函数我怎么能告诉它从字符串的开头开始,即我正在寻找等同于的全文 喜欢 'some_term%'。

我知道我可以使用 like,但由于我已经设置了全文索引,并且该表预计有数千行,所以我更愿意使用 Contains。

谢谢!

最佳答案

你想要这样的东西:

Rather than specify multiple terms, you can use a 'prefix term' if the terms begin with the same characters. To use a prefix term, specify the beginning characters, then add an asterisk (*) wildcard to the end of the term. Enclose the prefix term in double quotes. The following statement returns the same results as the previous one.

-- Search for all terms that begin with 'storm'
SELECT StormID, StormHead, StormBody FROM StormyWeather
WHERE CONTAINS(StormHead, '"storm*"')

http://www.simple-talk.com/sql/learn-sql-server/full-text-indexing-workbench/

关于SQL 包含 - 仅在开始时匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7388459/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com