Mysql: How To Create Trigger For Setting Creation Date For New Rows
I ran into a problem as I tried to create two TIMESTAMP columns in my database. One called created and one called updated. I figured it would be easy to set the default value of bo
Solution 1:
Your trigger needs to be "before insert", and you need to use SET instead of UPDATE:
CREATE TRIGGER task_creation_timestamp BEFORE INSERT ON tasks
FOR EACH ROW
SET NEW.created = NOW();
Post a Comment for "Mysql: How To Create Trigger For Setting Creation Date For New Rows"