Reputation: 135
I have been tried mysql trigger to set a field to value 1, if there is any update action happened in any column of the record.
I am newbie in trigger, so help me to set a value to 1, if updated record
Thanks
Upvotes: 1
Views: 149
Reputation: 464
CREATE TRIGGER t_name AFTER INSERT ON table_name
SET @attribute_name = 1;
Upvotes: 1
Reputation: 311563
This looks like a classic usecase for a before update
trigger:
delimiter //
CREATE TRIGGER mytable_upd_trg
BEFORE UPDATE ON mytable
FOR EACH ROW
BEGIN
SET NEW.special_field = 1;
END;//
delimiter ;
Upvotes: 0