i am currently practicing my SQL skills. I wanted to get all data in the past 1 minutes.
The query is SELECT * FROM menfesses WHERE created_at >= NOW() - INTERVAL 1 MINUTE;
But somehow, it returns all data.
I have also use date_add approach and nothing works
What did i do wrong? Thanks
2
Answers
The last five minutes must be select with a BETWEEN.
Also testing you should add
So that have a chance to debug it correctly
Between would only give you the correct data, as your test server could have dates later then now
Edit
a fiddle demonstrates my point https://dbfiddle.uk/c5Jlko65
You maybe off on the system you have
Probably your server time that’s not what you think it is.
This work with a 5 min laps.
SQL Fiddle
MySQL 5.6 Schema Setup:
Query 1:
Results: