new to DBA thanks to support with me.
Overview: I have groups, subgroups and users.
- The user can be the owner of the group, therefore, must be the owner of all its subgroups.
- A user can be a co-author or follower of a group, so he must be a co-author or follower of all his subgroups.
- User can only be a co-author or follower of a subgroup
The tables are as follows (simplified):
Group (topic_id, name)
Subgroup (subtopic_id, title, topic_id)
rel_Group (user_id, topic_id, type) // Determine the relationship of the user to the group (owner, collaborator or follower)
rel_Subgroup (user_id, subtopic_id, type) // Determine the relationship of the user to the subgroup (Owner, Collaborator or Follower)
User (user_id)
I want to create a trigger when a subgroup is created that will insert INSERT / UPDATE / DELETE strings in rel_Subgroup so that users who are the Owner, Collaborator or follower in the group, respectively, are the Owner, Collaborator or follower in the subgroup
This is the closest I received, but I still get: # 1415 - It is not allowed to return a result set from a trigger.
SQL Query
delimiter // create trigger Transfer_Rights_to_Subgroup after insert on Subgroup for each row begin select user_id,type from rel_Group where rel_Group.topic_id = NEW.topic_id; insert into rel_Subgroup VALUES (rel_Group.user_id,NEW.subtopic_id,rel_Group.type); END; // delimiter ;
I hope to sort the insert and then find out the update / deletion.
Any help greatly appreciated!
THX