In my service club db I have a persons table for members and a clubs table for clubs in our district of 68 clubs.
I have the club number/id and club name in both tables.
What I want do do is when the club number is changed in a person record (member has transferred between clubs)
I put the following trigger (using HeidiSQL v6.0) on table persons after update, but nothing happens. The code runs when I do it programatically or from a query browser.
Any ideas what I need to do to make this work?PHP Code:-- Intended to update clubname attribute in persons table when
-- a member is moved between clubnames by changing his/her club number
BEGIN
UPDATE persons
SET clubname = (
SELECT clubname
FROM clubs
WHERE persons.clubid = clubs.clubno
);
END
This will be the first time I've done a trigger, though I've been using MySQL/PHP for a number of years. Incidentally, I know this may not be the most efficient way of doing the clubname for the persons table, but I designed this when I was learning MySQL and fixing it is not near the top of my task list.
My thanks in advance.


Reply With Quote
Bookmarks