MySQL: Try to Port a Trigger from SQL Server
This has been discussed before by others


Making a column immutable in MySQL
What are some good methods of structuring a MySQL audit trail to be both immutable, and perform well for usage?


Your question is a little different in this instance. You may have to experiment with INSERT IGNORE or REPLACE for the desired effect.

You may need to also experiment with disabling the trigger midstream : Disable trigger for just one table