0
我在試圖創建下面的觸發器問題觸發器內:加入
CREATE TRIGGER loteria_loterias AFTER UPDATE ON loteria_loterias
FOR EACH ROW BEGIN
UPDATE
loteria_loterias l
JOIN loteria_tipos t
ON l.tipo = t.id
SET
NEW.fecha_fin = NEW.fecha_ini + interval t.duracion hour
WHERE c.cID=NEW.cID;
END
我有這個定義的表:
CREATE TABLE `loteria_loterias` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`tipo` int(11) unsigned NOT NULL,
`fecha_ini` datetime NOT NULL,
`fecha_fin` datetime DEFAULT NULL,
`ganador` varchar(60) CHARACTER SET utf8 DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `ganador` (`ganador`),
KEY `tipo` (`tipo`),
CONSTRAINT `loteria_loterias_ibfk_2` FOREIGN KEY (`tipo`) REFERENCES `loteria_tipos` (`id`),
CONSTRAINT `loteria_loterias_ibfk_1` FOREIGN KEY (`ganador`) REFERENCES `tegm_users` (`user_login`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=latin1
CREATE TABLE `loteria_tipos` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`nombre` varchar(60) NOT NULL,
`coste` int(11) NOT NULL,
`premio` int(11) NOT NULL,
`duracion` int(11) NOT NULL COMMENT '(en horas)',
`activa` tinyint(1) NOT NULL,
`x` int(11) NOT NULL COMMENT '(coordenadas del cartel)',
`y` int(11) NOT NULL COMMENT '(coordenadas del cartel)',
`z` int(11) NOT NULL COMMENT '(coordenadas del cartel)',
UNIQUE KEY `id` (`id`),
KEY `id_2` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
根據MySQL的:
#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 9
更正。但是我仍然收到一個錯誤(我已經更新了這個問題):S –
@Trollkemada:在[你的最新更新](http://stackoverflow.com/revisions/17490965/2)中,你似乎已經刪除了'; '這是終止'UPDATE'命令。 – eggyal
謝謝。仍然錯誤:用新錯誤編輯的S問題 –