I want to query all events that are going on right now. Each events
record has at
and minutes
fields for the time range of the event. I might query the events
table like this:
SELECT * FROM events WHERE at >= NOW() - INTERVAL '2 hours' AND at <= NOW()
This assumes the event is 2 hours long. But I don't know that. The actual length is stored in the minutes
field. How can I use that field in my query? Or is there a better mechanism for me? I've unsuccessfully tried things like this:
SELECT * FROM events WHERE at >= NOW() - INTERVAL minutes ' minutes' AND at <= NOW()
One little caveat is that performance does matter, somewhat. There is a large number of events in our database and that is growing fast.