Mysql-PHP collects hourly data by month

Source: Internet
Author: User
This is the requirement. One copy of data is post every hour and written to the data table. Now, you need to query data by month. For example, if the data is queried at, the data is all data from September 1 on January 1, 0000 to September 6 on January 1, 1100. Now there are two problems...

This is the requirement.
One copy of data is post every hour and written to the data table.
Now, you need to query data by month. For example, if the data is queried at, the data is all data from September 1 on January 1, 0000 to September 6 on January 1, 1100.

Now there are two problems.
1. How should we design data tables in this scenario?
2. How can I write an SQL statement based on a specific month, for example, January 2015?

Now, I write the hourly data to data Table A (the fields are id, time, order_count, and time are in the unix timestamp format, that is, written in php using the time () function). Then, the sum calculation of the data in Table A is written to table B every hour. Finally, the data is queried through table B.
Thank you in advance.

Reply content:

This is the requirement.
One copy of data is post every hour and written to the data table.
Now, you need to query data by month. For example, if the data is queried at, the data is all data from September 1 on January 1, 0000 to September 6 on January 1, 1100.

Now there are two problems.
1. How should we design data tables in this scenario?
2. How can I write an SQL statement based on a specific month, for example, January 2015?

Now, I write the hourly data to data Table A (the fields are id, time, order_count, and time are in the unix timestamp format, that is, written in php using the time () function). Then, the sum calculation of the data in Table A is written to table B every hour. Finally, the data is queried through table B.
Thank you in advance.

This is a relatively simple data statistics... I don't know if I need to draw a wave chart ~,
Everyone else gives you the hourly data. You do not need to collect data by hour,
You just need to save the data every hour.
The table structure is basically
Id, data, time
Data is the data value.
Time indicates the time point of the data.HourTimestamp, that isIgnore minutes

Queries are indexed by time.

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.