MySQL Triggers

To create a new trigger, use the CREATE TRIGGER statement. You must give the trigger a unique name and then provide the timing, action, and table that will cause the trigger to fire. For example, to create a trigger that will fire every time a row is deleted from the products table, you would construct a trigger as follows:
 
CREATE TRIGGER trigger_name
BEFORE DELETE ON products
FOR EACH ROW
BEGIN
  ...
END



The timing for a trigger can be BEFORE or AFTER, indicating whether the trigger code should be executed immediately before or immediately after the SQL statement that causes the trigger to fire.
The keywords FOR EACH ROW are part of the CREATE TRIGGER syntax and are required in every trigger.