Update Column Using INSERT trigger
Posted on 2014-03-10
I really struggle when it comes to writing triggers so I figured I would ask the experts.
I have a table called "group_members" which has the following schema:
group_member_id PK int
group_id int FK to table "groups"
contact_id int FK to table "contacts"
Whenever a record is inserted into this table I want to do the following
Query the groups table for the ID of the group inserted above and retrieve the value groups.pricing_level
Then, update the field, contacts.pricing_level in the contacts table.
In other words, we add a member to a group, retrieve the pricing level for the group and update to contact to have the same level.
Any help appreciated. Trigger contexts always baffles me.