现在需要这样的一个效果,根据产品名,做模糊查询,得到其产品名相似的产品。
但是越精确的越靠前。
原本我的方式是:
alterfunction f_splitIncrease
(
@strSourcenvarchar(2000),
@strSplitStrnvarchar(100)
)
returns@tempTabletable(idintidentityprimarykey,onenvarchar(1000))
as begin declare@tempStrnvarchar(1000);
declare@startIndexint;
set@startIndex=1;
set@strSource=@strSource @strSplitStr;
while(@startIndex 0)
begin set@startIndex=charindex(@strSplitstr,@strSource,@startIndex 1);
if(@startIndex 0)
begin set@tempStr=left(@strSource,@startIndex-1);
if(@tempStr'')
begin insertinto@tempTablevalues(@tempStr);
end end end return end
调用select*from dbo.f_splitIncrease('the office seasons')
会得到
the the office the office seasons
这样三条记录,
再根据这个去做搜索,代码如下:
alterproc Proc_Product_Related
(
@namenvarchar(2000),
@splitStrnvarchar(100)=''
)
as begin declare@tempTabletable(
idintidentity(1,1)primarykey,
ProductIDint,
[Name]nvarchar(255),
ProductNonvarchar(50),
MemberPricemoney,
ThumbnailImgnvarchar(255),
ProductImgnvarchar(255)
)
if(@splitStrisNull)
begin set@splitStr='';
end begintransaction insertinto@tempTable selectdistinct ProductID,[Name],ProductNo,MemberPrice,ThumbnailImg,ProductImgfrom product p,(select*from dbo.f_splitIncrease(@name,@splitStr))f where p.namelike f.one 'br />if(@error 0)
begin rollbacktransaction end select*from@tempTable if@error 0
rollback else committransaction end
于是最精确的排在最下面。
但是由于模糊搜索the office时,已经包含了the office seasons,会出现记录重复。
现在要解决记录重复,如果使用distinct关键字的话,他的结果集就不是最精确的排在最下面。没有达到原本想要的效果。
这里该如何处理呀?
MS SQL Server的中文分词探索(3)
来源:互联网 发布日期:2011-09-09 17:17:27 浏览:18177次
导读: 现在需要这样的一个效果,根据产品名,做模糊查询,得到其产品名相似的产品。 但是越精确的越靠前。 原本我的方式是: alterfunction f_splitIncrease ( @strSourcenvarchar(2000), @strSplitStrnvarchar(100) ) returns@tempTabletable(idintidentityprimar...
相关内容
AiLab云推荐

最新资讯
本月热点
热门排行
-
如何买到便宜大碗的 5G 套餐?聊聊你也许不知道的 CPE、MiFi 和物联卡
阅读量:4478
-
爱立信中国区总裁方迎:5G发展仍面临两大挑战,“新质网络”将创造“新质价值”
阅读量:2543
-
东南亚多国邀中企合作开发5G网络,泰总理:愿同中方在多领域加强合作
阅读量:2377
-
苹果自研5G基带细节曝光:3年3款芯片,全面替代高通
阅读量:617
-
千亿规模!2024年运营商集采大盘点:5G建设集采仍占“大半壁江山”
阅读量:561
-
天翼智库饶少阳:AI+5G融合助推高阶广泛智能落地
阅读量:503
推荐内容
- 2025年第33届中国华东进出口商品交易会(上海华交会)
- 2025第十五届中国(郑州)塑料产业博览会(AllinPlas)
- 2025第二十届中国(临沂)小商品博览会
- 2025年加拿大多伦多矿业展PDAC
- 2025北方国际电机技术与节能科技展览会
- 2025第三十届届华南国际口腔展览会
- 2025CME第10届上海国际机床展(华机展)
- 2025第14届国际生物发酵展(济南展)(BIO)
- 2025中国(山东)国际工业节能技术与装备博览会
- 2025北方国际膜工业大会暨膜工业技术产品展览会
- 2025第十五届杭州网红直播电商及私域团购选品博览会
- 2025第十五届杭州全球新电商博览会
- 2025济南药交会
- 2025广州国际护肤用品展览会(迎河个护展 PCE)
- 2025第三十一届中国国际包装工业展览会(中国国际包装工业展 Sino-Pack 2025)
- 2025第三十一届华南国际印刷工业展览会(printing south china)
- 第九届广州国际氢科技产业博览会
- 2025第三十二届上海国际广告技术设备展览会(上海国际广印展 APPP EXPO)
- 2025 年日本国际照明LED 展览会