E
E
exaller2016-02-11 13:56:44
PHP
exaller, 2016-02-11 13:56:44

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

6 answer(s)
K
KerryDarko, 2016-02-11
@KerryDarko

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

A
Alexander Litvinenko, 2016-02-11
@edli007

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

A
Andrey, 2016-02-11
@VladimirAndreev

WHERE date='2016-02-11'
LIMIT 1

A
Andrey Burov, 2016-02-11
@BuriK666

GROUP BY date
// date - date only 2016-02-11

R
Rsa97, 2016-02-11
@Rsa97

SELECT DATE(`datetime`), AVG(`value`)
  FROM `table`
  GROUP BY DATE(`datetime`)

A
Anton Khmyrov, 2016-02-12
@vivcogit

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 question

Ask a Question

731 491 924 answers to any question