Example of trigger on after delete with update query mysqlBy Hardik Savani | April 5, 2016 | | 949 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;
- JQuery - Display loading image on ajax call example
- How to group by multiple columns in Laravel Query Builder?
- Solved - Access Not Configured. Google+ API (truncated...) on google console developer
- How to confige Elasticsearch in our local system
- How to disable model timestamps in Laravel 5.3?
- Order by using multiple columns and manually array field in Laravel?
- Bootstrap progress bar animate example using bootstrap-progressbar.js
- How to define Global Variables in Laravel 5?