I've a table with 4 columns: id (int), name (varchar), timefrom (time), timeuntil (time)
Now I would like to have all combinations where they have an intersection on the timefrom to timeuntil.
My current solution is that I load all the records and loop it in php for every full hour... but this costs me much performance.
Any Ideas, is this possible to solve in a Select?
I want to know which presences are sharing the same timefrom, timeuntil As an example:
#1 / whole day / 06:00:00 / 18:00:00 #2 / morning / 07:00:00 / 12:00:00 #3 / afternoon / 13:00:00 / 18:00:00
I would like to have the result:
#1, #2, #3 (the whole day shares the times with morning, afternoon) #2, #1 (the morning shares the times with the whole day) #3, #1 (the afternoon shares the times with the whole day)