I need help with a query. I am taking input from a user where they enter a time range between 00:00 to 23.59. So it could be like 10:00 to 12:00 or 12:00 to 18:00. Then I need a query to pull data from a table that has a match_time stored in time format. Here we can assume that 10:00 being min and 12:00 being max range.
So if a user did 10:00 to 12:00 and the table had entries for 1:00, 2:30, 10:00, 11:30, 12:00, 15:00, 19:00 and 22:00 it would find 10:00, 11:30, 12:00. using MySQL
match_time BETWEEN (CAST('10:00:00' AS time)) AND (CAST('12:00' AS time))
But if they pass 18:00 to 3:00 that should output 1:00, 2:30, 19:00 and 22:00, not sure how to achieve this. Please help.