How to create a trigger in MySQL Explain with example ?
In MySQL, a trigger corresponds to a set of actions running automatically when a particular change operation like SQL INSERT, UPDATE, or DELETE query is performed on a table.
CREATE TRIGGER data_backup BEFORE UPDATE ON users
FOR EACH ROW
IF NEW.amount < 0 THEN
SET NEW.amount = 0;
ELSEIF NEW.amount > 100 THEN
SET NEW.amount = 100;
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.