我要在xampp中創建觸發器。在MySql中創建觸發器時出錯5.5.27
CREATE TRIGGER testref BEFORE INSERT ON test1
FOR EACH ROW
BEGIN
INSERT INTO test2 SET a2 = NEW.a1;
DELETE FROM test3 WHERE a3 = NEW.a1;
UPDATE test4 SET b4 = b4 + 1 WHERE a4 = NEW.a1;
END;
,但我有錯誤:
CREATE TRIGGER testref BEFORE INSERT ON test1
FOR EACH
ROW
BEGIN
INSERT INTO test2
SET a2 = NEW.a1;
MySQL said: Documentation
#1064 - You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near '' at line 4
之前,我創建4個表:
CREATE TABLE test1(a1 INT);
CREATE TABLE test2(a2 INT);
CREATE TABLE test3(a3 INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE test4(
a4 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
b4 INT DEFAULT 0
);
請幫助我。萬分感謝!
我試圖在phpmyadmin中創建它。我如何解決它? –
增加了一個更明確的例子。我不知道phpmyadmin如何與事物混淆。 –