How to count the data of php mysql on a minute-by-minute basis

how is the data of the day grouped by minutes in php mysql? that is, 1440 pieces of data
0
MYSQL when there is no data. Is there a corresponding query syntax?

Mar.24,2021

http://sqlfiddle.com/-sharp!9/3d58.


then save yourself a minute, and then group by time. Or, convert the time found out to the year, month, day and hour, and then group it.


select count(*), left(create_time, 10) as d from tbl where create_time > '2018-06-01' group by d;

you can definitely do it (simply, do an intercept operation), but in fact, this operation is very time-consuming, each query has to be calculated, the purpose of the database is best to do the query (combined with the index to improve the query speed), you can put this task to the foreground , the background only provides data.


mysql has the function to convert the time format directly to a unified format, which can be converted to a time format of only hours and minutes according to your needs, and then group statistics according to the time. Of course, mysql can only do queries, it is best to do queries only, but in this case, mysql is more resource-saving, so make your own choice.

Menu