Skip to content
Advertisement

SQL Trigger – Having one is messing up new SQL queries

I am able to manually execute the following code:

However, if I try creating a Trigger with the same code as above, I get this error when creating a new user in my database:

Can’t update table ‘members’ in stored function/trigger because it is already used by statement which invoked this stored function/trigger (1442)

Can anybody help fix the trigger?

Thanks!

EDIT 1:

Full trigger definition:

Advertisement

Answer

Since you cannot refer to the same table in a trigger’s definition (for reading or writing), the trigger handling can be simplified based on setting the member_group_id to 6 if field_2 is Teacher:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement