这是我写的,sql语句部分有错误,第二个old处报错,不知道并列的删除要怎么写,求指点
CREATE TRIGGER sche_building_del AFTER DELETE ON classroomtbl FOR EACH ROW
BEGIN
DELETE FROM schedulebasetbl WHERE schedulebasetbl.`classroom_id`=old.id;
DELETE FROM schedulechangetbl WHERE schedulechangetbl.`classroom_id`=old.id;
END sche_building_del;
首先你要重新设定一下SQL语句分隔符,因为默认是分号(;),所以你的触发语句中;会当作举姿困是SQL语句的分割,就会出错,按照册扰你上面的语句应该这正念样写:
DELIM
ITER $
CREATE TRIGGER sche_building_del AFTER DELETE ON classroomtbl FOR EACH ROW
BEGIN
DELETE FROM schedulebasetbl WHERE schedulebasetbl.`classroom_id`=OLD.id;
DELETE FROM schedulechangetbl WHERE schedulechangetbl.`classroom_id`=OLD.id;
END$
上面的DELIMITER $就是申明$为SQL的分隔符,你试一试