Example of trigger on after delete with update query mysqlBy Hardik Savani | April 5, 2016 | | 3489 Viewer | Category : PHP MySql SQL
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;
- Solved - gulp error cannot find module laravel-elixir
- Automatically Refresh or Reload a Page using jQuery Example
- How to create and use Middleware in Laravel 5?
- Select box with search option example in Jquery using Chosen Plugin
- Laravel 5 Join with subquery in Query Builder Example
- How to remove special characters by mysql custom function.
- Laravel 5 - Dynamic Dependant Select Box using JQuery Ajax Example - Part 2
- PHP - Getting Started PHPUnit test with simple example