In MySQL, a trigger corresponds to a set of actions running automatically when a particular change operation like SQL INSERT, UPDATE, or DELETE query is performed on a table.

You can either write command in MySQL like this:

Example

                                        

CREATE TRIGGER data_backup BEFORE UPDATE ON users
   FOR EACH ROW
   BEGIN
     IF NEW.amount < 0 THEN
        SET NEW.amount = 0;
     ELSEIF NEW.amount > 100 THEN
       SET NEW.amount = 100;
     END IF;
   END;//

Suggest An Answer

No suggestions Available!