There are many ways to query MySQL. The MySQL query statements described below are used to query records that repeat the most times, which is helpful for learning MySQL query.
In some applications, we need to query the records with the most repeated times. Although this is a very simple query statement, it is still difficult for many beginners.
- SELECT keyword, count( * ) AS count
- FROM article_keyword
- GROUP BY keyword
- ORDER BY count DESC
- LIMIT 20
-
This query statement returns the 20 most repeated keyword 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 number of keyword repetitions in the article_keyword table count) the top 6 values. A unique record is returned by adding DISTINCT.
Connection between MySQL column type selection and query efficiency
Troubleshooting of MySQL query timeout
Transformed from the MySQL Query Class of discuz
How MySQL query optimizer works
MySQL query results are sorted by a certain value