I was wanting a mysql trigger for a specific field. When a NULL
value is inserted into this field I would like to replace it with a default value. I know this code is not correct, but it would give you an idea of what I want.
CREATE TABLE IF NOT EXISTS example(
id INT NOT NULL AUTO_INCREMENT,
parent_id INT NOT NULL
);
CREATE TRIGGER insert_parentId_trigger BEFORE INSERT ON example
FOR EACH ROW BEGIN
IF parent_id = NULL THEN
SET parent_id = 0;
END IF
END;