I am trying to write a query for my database.
Basically, I have an array of strings containing room numbers that I need to match up with another database containing events in the rooms. I want to find the next event happening in that room. Ex: I have an array room containing [ZACH102, ZACH103]. I want to find the database to return the next event happening in ZACH102 and ZACH103. I know how to find events for 1 room using the query below. But how do I do this using an array?
select name,
eventtime,
(eventtime - currenttime) > 0 as time_from_test
from the_table
where the_table.room = ZACH102
order by time_from_test
limit 1
Thanks in advance!
EDIT: Sorry if my explanation wasnt clear enough, but I only want the earliest event in each room in the array. Note the limit 1 at the end.
EDIT: Yes, I put the limit 1 there to mean that I only want 1 event from ZACH 102 and then i want 1 event from ZACH 103. I explained that the code above only finds events for 1 room.