Help with MySQL trigger / loops

Discussion in 'MySQL' started by PoPSiCLe, Jan 12, 2013.

  1. #1
    Hi. I have a table in my database which contains the following:

    timesheet_days:
    tt_id, tt_name, tt_1, tt_2, tt_3, tt_4, tt_5. tt_6, tt_7 - where the tt_X represents each day of the week.

    This table is populated by a trigger from another table when a new location is placed into another table. This works just fine.

    Now I want to populate another table with work-shifts when there is a new entry into this table.

    Making a trigger which makes an entry into the shift-table isn't a problem, but I want one entry pr. day - something like this:

    When a new entry is entered into timesheet_days -> trigger -> new entries are made into the timesheet_shifts table for each day

    This means I need to loop through the different days (tt_X) in one row in the timesheet_days table

    Anyone have a code akin to this available?

    I'm fairly new to triggers, and this has got me stumped
     
    PoPSiCLe, Jan 12, 2013 IP