I think I summed nicely it up in the title. I want to select online users from a specific time to another specific time. My table look like this:
CREATE TABLE on
Use DATE_SUB to subtract time from the DATETIME returned from NOW():
SELECT o.*
FROM ONLINE o
WHERE o.time >= DATE_SUB(NOW(), INTERVAL 15 MINUTE)
SELECT o.*
FROM ONLINE o
WHERE o.time BETWEEN DATE_SUB(NOW(), INTERVAL 60 MINUTE)
AND DATE_SUB(NOW(), INTERVAL 15 MINUTE)
Duplicate handling costs extra.