Reputation: 35349
I want to select a row only if it is younger than a set time, in this case 5 minutes: I'm not sure how to tell MySQL that 5
is minutes, and not an int. As such, I can't do this:
SELECT data from dataTable WHERE data.createdAt < 5
createdAt is a datetime field.
Upvotes: 0
Views: 702
Reputation: 449613
This should do the job:
SELECT data FROM dataTable
WHERE data.createdAt > DATE_SUB(NOW(), INTERVAL 5 MINUTE)
Upvotes: 2