I'm trying to make a datetime field that automatically gets updated with the current time only if there was a change to a certain field.
It seems I have a syntax error.
I try to have last_progress_date
that gets the date when the progress_percentage
is updated/edited:
CREATE OR ALTER TRIGGER last_progress_date
ON wp_task_mgr
AFTER UPDATE
AS BEGIN
IF UPDATE (progress_percentage)
SET last_progress_date = GETDATE()
END
Best Answer
The code doesn't look like valid Mysql code:
ALTER
is not a valid optionAS
in MysqlIF UPDATE(column)
UPDATE(column)
tests whether column updated in SQLServer, not in MysqlIF
syntax is invalid (check https://dev.mysql.com/doc/refman/5.5/en/if.html)BEFORE
trigger, not inAFTER
.You need something like