This seems like it should be easy, but I’m banging my head against the wall. I’m creating a site in php/mysql where, when a user pulls up a day of the week, it will list assignments given to them grouped by chunks of time, e.g., 8-11, 11-14, etc.
I have a table set up like this, where the fields are intended to reference another table containing tasks. Each integer corresponds to a unique task in the tasks table.
8-11 11-14 14-17 17-20 20-23
Mon 1 3 4 1 2
Tues 1,3 4 5 6 7
Wed 1,2,3 5 4 8 9
As you can see, some days have repeating tasks at different times (e.g., on Monday, task 1 is performed during the 8-11 and 17-20 slot). And most baffling for me is how to set up the table or join multiple tables to address time slots with multiple tasks, e.g., the Wed 8-11 shift has three tasks, 1, 2, and 3.
My question: can you suggest table structure(s) that would be optimal for this, and an example query to retrieve the tasks for a given day? THANK YOU. Any help is greatly appreciated.
** EDIT ** Here’s what I’m trying to ask: looking at Wed 8-10, how can I pull the three tasks from the task table?
http://sqlfiddle.com/#!2/2130b/8