Example of trigger on after delete with update query mysqlBy Hardik Savani | April 5, 2016 | | 715 Viewer | Category : PHP MySql SQL
Share this post:
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:
CREATE TRIGGER add_ban_counter_in_users
AFTER DELETE ON `chat_messages`
FOR EACH ROW
SET remove_counter = users.remove_counter + 1
WHERE users.id = old.user_id;
- Laravel 5 - multiple files download with response example
- Bootstrap - Jquery multiple select with checkboxes example using bootstrap-multiselect.js plugin
- How to upgrade node.js version in Ubuntu?
- How to select concat columns with Laravel Query Builder?
- How to use elasticsearch from scratch in laravel 5?
- Laravel 5.3 - Form Input Validation rules example with demo
- How to remove special characters by mysql custom function.
- Bootstrap year picker example using datepicker js