As you can see from the answers here there is more than one way to select rows from the database that are less than 5 minutes old.
You can also use the CURRENT_TIMESTAMP function in MySQL to get the current timestamp, and then compare it to the timestamp of the rows you want to select in your WHERE clause. For example:
SELECT * FROM table_name WHERE timestamp_column >= CURRENT_TIMESTAMP - INTERVAL 5 MINUTE;
This will select all rows from the table_name
table where the value in the timestamp_column
is less than 5 minutes old. MySQL CURRENT_TIMESTAMP is basically just a synonym of NOW.
You can also use the TIMESTAMPADD function to add a specific number of minutes to the current timestamp, and then use that result in your WHERE clause to select rows that are less than a certain number of minutes old:
SELECT * FROM table_name WHERE timestamp_column >= TIMESTAMPADD(MINUTE, -5, CURRENT_TIMESTAMP);
This will also select all rows from the table_name
table where the value in the timestamp_column
is less than 5 minutes old.