我在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;”没有执行就是离开触发器并且不运行被触发的插入!
有人可以帮助我吗?
由于