I’m trying to create a trigger in phpMyadmin (MySQL)
I have two tables, members and subscriptions. subscriptions has a date field (the date when the subscription expires) and so does members. The two tables have a common member.ID field.
When a new subscription record is inserted, I want to update the expiry date field in the members table.
The trigger setup is on table subscriptions, update after insert
This what I have entered into the create trigger dialouge in phpmyadmin:
UPDATE members
SET members.mbrshp_expiry_date = subscriptions.expiry_date
WHERE members.mbrshp_number = subscriptions.mbrshp_number
When this code triggers it comes back with an error. The two subscription fields referenced in the clause are not found.
Any help would be greatly appreciated.
Fields can be referenced in a trigger by using the NEW prefix.
This functions correctly 🙂