0

我设计了一个简单的网站,使用户可以在 MYSQL 数据库上进行搜索。搜索方法也很简单:用户在文本字段中输入一个单词,然后在数据库中搜索。现在我想在这个网站上包含一个搜索最多的单词的表格,直到现在我才找到任何东西,除了这句话:

select distinct column
       , count(1) as total
    from dept
group by column
order by total desc
   limit 5

但这并没有检索到我想要的东西。你知道我是如何得到这个结果的吗?先感谢您!

4

1 回答 1

1

一个小型网站的简单示例:

每次搜索后,向表中添加一行searched。添加时间戳的奖励积分。

insert into searched (keyword, timestamp) values ('foo', 1234567890);

从那里:

select keyword, count(*) as total from searched
  group by keyword order by total desc limit 5;

当然,对于这样简单的事情,我会使用 redis。

于 2013-03-09T16:35:54.113 回答