I am writing a query for my database and basically I want to query a database for events happening in each room. Meaning that i want to find the earliest event happening in room 1 and the earliest event happening in room 2.
Below I have the code for performing this query for 1 room. This code only returns the earliest event in room 2. How can I perform a query where I find the earliest event for room 1 and the earliest event for room 2 and return it in a single query?
This would be performing a query on each element of an array but in a single query. Is this possible or would I have to write a query for each room?
select name,
eventtime,
MIN(eventtime - currenttime) as time_from_test
from the_table
where the_table.room = Room1
group by the_table.room
order by time_from_test
limit 1
Thanks in advance