开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜