Can I create trigger after the update of specific columns in MySQL?

Forums SQLCan I create trigger after the update of specific columns in MySQL?
Staff asked 3 years ago

Answers (1)

Add Answer
monika gabani Marked As Accepted
Staff answered 3 years ago

You can’t trigger on a particular column update in SQL. It is applied on a row.

You can put condition for column in your trigger with an IF statement, as below:

 

CREATE TRIGGER myTrigger AFTER UPDATE ON employeeTable
FOR EACH ROW
BEGIN
IF !(NEW.column1 <=> OLD.column1) THEN
–your statements here
END IF;
END;

Subscribe

Select Categories