MySQL queries the most repeated occurrences of the record

Source: Internet
Author: User
Tags mysql query

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.

    1. SELECT keyword, COUNT (*) as Count
    2. From Article_keyword
    3. GROUP by keyword
    4. ORDER by Count DESC
    5. LIMIT 20

This query statement returns the maximum number of keyword repetitions (count) of 20 records in the Article_keyword table.

    1. SELECT DISTINCT Count (*) as Count
    2. From Article_keyword
    3. GROUP by keyword
    4. ORDER by Count DESC
    5. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.