1

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

2 Answers 2

1

CREATE TRIGGER t_name AFTER INSERT ON table_name

SET @attribute_name = 1;

Sign up to request clarification or add additional context in comments.

Comments

0

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 ;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.