0
我想寫以下觸發語法錯誤:MySQL的 - 上觸發
DELIMITER $$
CREATE TRIGGER trigger_test_1 AFTER INSERT ON test FOR EACH ROW
BEGIN
DECLARE sID INT;
DECLARE m INT;
DECLARE a INT;
DECLARE c INT;
SET sID = NEW.s;
SELECT MONTH(NOW()) INTO m;
SELECT YEAR(NOW()) INTO a;
SELECT COUNT(*) INTO c
FROM testt t
WHERE t.m = m AND t.a = a AND t.sID = sID;
IF c = 0 THEN
INSERT INTO testt VALUES (m, a, sID, '', '');
END $$
DELIMITER ;
的錯誤是:
ERROR 1064 (42000): 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 15
的表是很簡單的:
CREATE TABLE test(
s INT
);
CREATE TABLE testt(
m INT,
a INT,
sID INT,
t VARCHAR(200),
d VARCHAR(500)
);
謝謝。
謝謝,我擔心其他方面,錯過了這個小小的錯誤。 – Minoru
從問題開始之前必須等待一段時間才能接受任何問題。我會盡快做到。 – Minoru