关键字新闻查询?

xulisha123 2011-03-19 09:51:47
我有一种新闻表里面存了关键字

已有表数据
Id | keywords3
1 |“北京 楼盘 4W一平米”
2 |“北京 奥运 2008 ”
3 |“北京 2008 诡异油画”

比如我现在有:
北京 奥运 2008 吉祥物

查询结果需要 :
Id | keywords3
2 |“北京 奥运 2008 ”
3 |“北京 2008 诡异油画”
1 |“北京 楼盘 4W一平米”


要查找关键字符合的新闻, 关键字符合越多则排前面


...全文
106 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
AcHerat 2011-03-19
  • 打赏
  • 举报
回复
又见全文索引,对这个机制不是很了解!。。。
--小F-- 2011-03-19
  • 打赏
  • 举报
回复
我在猜测需要用到全文索引的模糊查询
AcHerat 2011-03-19
  • 打赏
  • 举报
回复
可能麻烦,输入的不知道有多少个!!!
dawugui 2011-03-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 acherat 的回复:]
SQL code

select *
from tb
order by (case when charindex(N'北京',keywords) then 4 else 0 end) +
(case when charindex(N'奥运',keywords) then 3 else 0 end) +
(case when charindex(N'……
[/Quote]

我估计他是这个意思:

select *
from tb
order by (case when charindex(N'北京',keywords) then 1 else 0 end) +
(case when charindex(N'奥运',keywords) then 1 else 0 end) +
(case when charindex(N'2008',keywords) then 1 else 0 end) +
(case when charindex(N'吉祥物',keywords) then 1 else 0 end)

xulisha123 2011-03-19
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 ssp2009 的回复:]
北京 奥运 2008 吉祥物 是输入的参数还是什么?
[/Quote]是输入参数
xulisha123 2011-03-19
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 ssp2009 的回复:]
北京 奥运 2008 吉祥物 是输入的参数还是什么?
[/Quote]

不是固定的,, 每一篇的都不一样, 我只是举个例子
快溜 2011-03-19
  • 打赏
  • 举报
回复
北京 奥运 2008 吉祥物 是输入的参数还是什么?
AcHerat 2011-03-19
  • 打赏
  • 举报
回复

select *
from tb
order by (case when charindex(N'北京',keywords) then 4 else 0 end) +
(case when charindex(N'奥运',keywords) then 3 else 0 end) +
(case when charindex(N'2008',keywords) then 2 else 0 end) +
(case when charindex(N'吉祥物',keywords) then 1 else 0 end)

--没有规则不好弄!

22,300

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧