before
insert
and checks & replaces gender valuesDROP TRIGGER IF EXISTS before_student_insert;
DELIMITER $$
CREATE TRIGGER before_student_insert BEFORE INSERT
ON students
FOR EACH ROW
BEGIN
INSERT INTO log (description)
VALUES ('One student will be inserted');
IF (NEW.gender = 'Female') THEN
SET NEW.gender = 2;
ELSE
SET NEW.gender = 1;
END IF;
END$$
DELIMITER ;