First, create the field for the timestamp in the table you want.
| 1 | ALTER TABLE `table` ADD `modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ; | 
Then, create the trigger. Just replace the word “table” with your table name.
| 1 2 3 4 5 6 7 8 9 10 11 | DELIMITER // DROP TRIGGER IF EXISTS table_trigger// CREATE TRIGGER table_trigger BEFORE UPDATE ON table FOR EACH ROW BEGIN IF NEW.modified = '0000-00-00 00:00:00' THEN SET NEW.modified = NOW(); END IF; END;// DELIMITER ; | 
