Answer the question
In order to leave comments, you need to log in
How can I get 1 record per day from MySQL?
There is a table with certain data. And you need to draw a graph.
For the graph, all data is not needed, 1 value per day is enough, for example.
How can this be implemented? PHP
A small explanation: I need to display all records from the database, but only with a frequency of no more than 1 per day.
Answer the question
In order to leave comments, you need to log in
The sample must be put in some script. And add this script to cron and configure it to run this script once a day
. This is on the server side. True, this is not exactly php ..
There is no other way
This can also be done using SQL, in some version (long ago) they built in the cron muscle, google the syntax, but in general it’s not difficult to make a table with current data for a chart, and enter data into it according to a schedule
SELECT DATE(`datetime`), AVG(`value`)
FROM `table`
GROUP BY DATE(`datetime`)
Either take the average as advised above, or if you just need any value per day, then you can:
SELECT DATE(`datetime`), FIRST(`value`)
FROM `table`
GROUP BY DATE(`datetime`)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question