Okay, I have two tables. One is events
and the other is occurs
. The event
table is basic, the event, it's ID, its description, etc... The occurs
table is linked to the events
table using the event ID; its basically a table of times for the event. For instance, if an event occurs every Tuesday, then an event will have an occurrence every Tuesday night in the database.
By default, the a row in the events
table does not have any timestamps in it, those are all in the occurs
table. However, for some reason or another I have the need to get the results of the events
table and also have a timestamp on it. So what I would like to do is use a query to the events
table, linked to a single row in the occurs
table. The part I am stuck on is which occurrence to get.
If the event has any occurrence after the current time, I would like to simply get the next upcoming occurrence. However, if it is a past event, with no upcoming occurrence, I would like to get the most recent occurrence (last).
Anyone got any tips or hints on how to get this done?