MySQL Forums
Forum List  »  Triggers

can u solve this?
Posted by: benny sheerin
Date: June 19, 2006 11:00AM

hi guys, got a complicated one here.

i have four tables: students_table, clubs_table, student_club_link_table and a details_table. a student can be a member of many clubs hence the link table.

the details_table basically nearly holds all the info in both the student and club tables combined so that my php front end has only to query one table and not three to get its desired results (seems crazy but it needs to be this way).

i need to be able to update the details table when either a new student is entered in the student table (with club is specified), and when a student joins/resigns more clubs.

a simplified view of what the details table looks like:

:: firstname :: surname :: club ::
|| john || smith || boxing ||
|| john || smith || rowing ||
|| ann || jones || karate || etc.

I was thinking of using a trigger after an insert on the student table to update the details table, but this trigger will have to cycle through the student_club_link_table and if the student is a member of more than one club reflect this in the details table.

can this be done in triggers? if so any suggestions on the syntax, or if triggers cant help any suggestions on what can? im using mySQL version 5.0.2 by the way.

many thanks in advance for any help, im really stuck on this one!

benny

Options: ReplyQuote


Subject
Views
Written By
Posted
can u solve this?
3273
June 19, 2006 11:00AM
2189
June 19, 2006 11:40AM
2142
June 20, 2006 03:14AM
1994
June 20, 2006 12:48PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.