Example of trigger on after delete with update query mysql
In this post we will give you information about Example of trigger on after delete with update query mysql. Hear we will give you detail about Example of trigger on after delete with update query mysqlAnd how to use it also give you demo for it if it is necessary.
Sometimes we need to fire trigger like after delete update some fields of another tables. for example if you have chat_message tables and when remove row on this table then we need to update “remove_counter(remove_counter + 1)” on users table. i did give you bellow example you can see how to write trigger code:
Example:
delimiter //
CREATE TRIGGER add_ban_counter_in_users
AFTER DELETE ON 'chat_messages'
FOR EACH ROW
BEGIN
UPDATE 'users'
SET remove_counter = users.remove_counter + 1
WHERE users.id = old.user_id;
END
Hope this code and post will helped you for implement Example of trigger on after delete with update query mysql. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs