Skip to content

Instantly share code, notes, and snippets.

@marcelogrsp
Created July 3, 2020 21:43
Show Gist options
  • Save marcelogrsp/b6628d3b5a114bd4ec94c7fa8efeac96 to your computer and use it in GitHub Desktop.
Save marcelogrsp/b6628d3b5a114bd4ec94c7fa8efeac96 to your computer and use it in GitHub Desktop.
DELIMITER $$
CREATE TRIGGER `TRIGGER_NAME` BEFORE UPDATE ON `TABLE_NAME`
FOR EACH ROW
BEGIN
IF (NEW.FIELD_NAME is not null) THEN
SET NEW.FIELD_NAME = CURRENT_TIMESTAMP();
END IF;
END $$
DELIMITER ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment