Home  >  Article  >  Database  >  mysql查询数据库中出重复次数最多的记录

mysql查询数据库中出重复次数最多的记录

WBOY
WBOYOriginal
2016-06-07 17:51:183133browse

文章利用了count(*)和broupby 及order by来实现了mysql查询数据库中出重复次数最多的记录并且 以最多降序列出。

 代码如下 复制代码
SELECT keyword, count( * ) AS count
FROM article_keyword
GROUP BY keyword
ORDER BY count DESC
LIMIT 20

此段查询语句返回 article_keyword 表中 keyword 重复次数(count) 最多的20条记录。

 代码如下 复制代码
SELECT DISTINCT count( * ) AS count
FROM article_keyword
GROUP BY keyword
ORDER BY count DESC
LIMIT 6

此段查询语句返回 article_keyword 表中 keyword 的重复次数(count) 排名前 6 的数值。通过添加 DISTINCT 返回唯一记录

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn