我在 phpMyAdmin 中有这个触发器
DELIMITER $$
CREATE TRIGGER `DuplicateRows` BEFORE INSERT ON `infocontacts`
FOR EACH ROW
trig : BEGIN
DECLARE num INTEGER DEFAULT 0;
IF( NEW.phone <> 'NULL' ) THEN
SELECT COUNT( * ) INTO num FROM infocontacts WHERE phone = NEW.phone;
IF( num >0 ) THEN
INSERT INTO duplicated( name, surname, phone, email, profession, province)
VALUES (NEW.name, NEW.surname, NEW.phone, NEW.email, NEW.profession, NEW.province);
LEAVE trig;
END IF ;
END IF ;
END
指令“LEAVE trig;” 没有执行即离开触发器并且不运行被触发的插入!
有人能帮我吗?
谢谢