MySQL by month table, PHP How to do summary statistics query, sorting, paging

Source: Internet
Author: User

Requirements background

Group table

Group

Chat History Table

By month table, as

Chat_message_2015_04

Chat_message_2015_05

Chat_message_2015_06

Table structure

Chattime//message Time
GroupID//Group ID

Requirements Description

    1. Given a time period, such as the day/last 7 days/month/2015-04-12 ~ 2015-06-17, count the number of individual group's message in a given time period
    2. Sort and page out the group according to the number of message statistics

Reply content:

Requirements background

Group table

Group

Chat History Table

By month table, as

Chat_message_2015_04

Chat_message_2015_05

Chat_message_2015_06

Table structure

Chattime//message Time
GroupID//Group ID

Requirements Description

    1. Given a time period, such as the day/last 7 days/month/2015-04-12 ~ 2015-06-17, count the number of individual group's message in a given time period
    2. Sort and page out the group according to the number of message statistics

1.UNION
2, if InnoDB sub-table, you can use the merge processing.

Get a straight-up list of statistical data

If possible, do not use a sub-table design, table partitioning, so that the query will not need special processing. If you plan your index, performance should be fine.

  • 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.