MySQL queries the most repeated occurrences of the record
Http://database.51cto.com/art/201011/235139.htm
2010-11-25 14:40 Anonymous Internetfont Size:T | T
For MySQL database, query is always the most important function, the following will teach you to query the most repeated occurrences of the record, for your reference.
Ad:51cto mobile app Security Salon! It's going to be full now, slowed no seats!
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