K
K
Kirill2021-05-16 16:47:09
MySQL
Kirill, 2021-05-16 16:47:09

How to pull out all records from the database for the last 30 seconds, taking into account the user ID?

Hello everyone!)

Guys, I know that the question is very simple and damn it, very stupid, but I even earned so much that I got lost in 3 pine trees)

The task is simple, you need to select all records from the database, taking into account the user ID for the last 30 seconds and calculate their number, I write this request

SELECT COUNT(*) FROM count_check WHERE id=555334444444 AND created_at >= (now() - interval 30 second)


and it always returns zero. I tried to use the DATE_SUB () function, everything is the same.

Please tell me what am I doing wrong? Something strange, thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nord Dev, 2021-05-16
@Lobanov

Execute the query SELECT NOW(); and compare with the time of the last records, otherwise you can create with one date / time zone, and now () produces a different date? And check if those columns are needed in the query)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question