phpmyadmin版本5.1中的触发语法错误

时间:2014-02-11 13:21:42

标签: php mysql phpmyadmin mysql-error-1064 mysql-5.1

SQL查询 -

CREATE TRIGGER `trigger_insert` AFTER INSERT ON `user`
    FOR EACH ROW BEGIN
        INSERT INTO `credentials` (`UserId`,`Password`,`UserType`,`Status`) 
            VALUES (NEW.UserId,NEW.Password,'2',NEW.Status);
    END;
DELIMITER ;

错误 -

  

#1064 - 您的SQL语法出错;检查手册   对应于您的MySQL服务器版本,以便使用正确的语法   靠近''第3行

需要帮助......提前谢谢:)..

2 个答案:

答案 0 :(得分:0)

我认为是分隔符问题:

DELIMITER $$

CREATE TRIGGER `trigger_insert` AFTER INSERT ON `user`
 FOR EACH ROW BEGIN
 INSERT INTO `credentials` (`UserId`,`Password`,`UserType`,`Status`) VALUES (NEW.UserId,NEW.Password,'2',NEW.Status);
END$$

DELIMITER ;

答案 1 :(得分:0)

对于您的情况,您可以使用此声明 -

CREATE TRIGGER `trigger_insert` AFTER INSERT ON `user`
 FOR EACH ROW
 INSERT INTO `credentials` (`UserId`,`Password`,`UserType`,`Status`) VALUES (NEW.UserId,NEW.Password,'2',NEW.Status);

What is the DELIMITER in MySQL and what it’s used for.