MySQL query a lot of methods, the following for you to introduce the MySQL query statement to achieve the most repeated query records, for learning MySQL query has a good help.
In some applications, we need to query some of the most repeated records, although this is a very simple query, but for many beginners, it is still a bit difficult, special post this article for reference.
- SELECT keyword, COUNT (*) as Count
- From Article_keyword
- GROUP by keyword
- ORDER by Count DESC
- LIMIT 20
This query statement returns the maximum number of keyword repetitions (count) of 20 records in the Article_keyword table.
- SELECT DISTINCT Count (*) as Count
- From Article_keyword
- GROUP by keyword
- ORDER by Count DESC
- LIMIT 6
This query statement returns the top 6 number of repetitions (count) of keyword in the Article_keyword table. Returns a unique record by adding DISTINCT.
MySQL queries the most repeated occurrences of the record