M
M
Maxim2014-12-16 01:21:51
MySQL
Maxim, 2014-12-16 01:21:51

How to select rows with a gap in time?

There is a table in which the data is written every minute. Which query can select rows after a certain time interval? At the moment, the task is only to select every hour (0:00, 01:00, 02:00, ... , 23:00), every half hour and every 15 minutes.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2014-12-16
@z17

Or add a field with the time of adding, and make a selection on it.
Or, with each request, save the last new record of the interval somewhere, and use it to navigate which records are new (this option is obviously worse).

A
Alexey Solomakha, 2014-12-18
@KamaZz

SELECT * FROM `table` WHERE TIME(`column`) BETWEEN '21:00:00' AND '22:00:00'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question