Php mysql check if records exist within 3 minutes of now

How can i do a query to check if any records exist in my mysql table within 3 minutes of the currenct time?

quite easy, save a timestamp / datetime when you insert a row and then use a limitation of … timestamp >= NOW() - INTERVAL 3 MINUTE

By adding a column for creation date, e.g.


creation_date TIMESTAMP,

Populate it on insertion with CURRENT_TIMESTAMP

Now, calculate the difference in minutes from the creation date until now using TIMESTAMPDIFF as follows:


SELECT *
FROM my_table
WHERE timestampdiff(MINUTE, creation_date, now())<3