select query for time interval in mysql and php
select query to select all records that were inserted in 15 minutes.for ex if now time is 10:00 then it shoulld fetch all record in开发者_如何学JAVAserted from 9:45 to 10:00
Assuming you have a DATETIME
column named created
in your table:
SELECT id FROM tablename
WHERE ((created > DATE_SUB(NOW(), INTERVAL 15 MINUTE))
AND (created < NOW()))
select * from table WHERE datetimeField BETWEEN date_add(NOW(),INTERVAL -15 MINUTE) AND NOW();
精彩评论