【发布时间】:2013-07-20 10:15:52
【问题描述】:
我在我的 mysql 触发器中声明了一些变量
DELIMITER //
CREATE TRIGGER lestrigger
AFTER INSERT ON examinations
FOR EACH ROW
BEGIN
DECLARE the_last_inserted_id INT ;
DECLARE the_class_id INT;
DECLARE the_year_id INT;
SET the_last_inserted_id = LAST_INSERT_ID();
SET the_class_id = select examination_class_id from examinations where examination_id = the_last_inserted_id;
SET the_year_id = select examination_class_year_id from examinations where examination_id = the_last_inserted_id;
insert into examination_data (ed_cs_id,ed_examination_id) select cs_id from class_students where cs_class_id = the_class_id AND cs_year_id = the_year_id,the_last_inserted_id;
END
//
DELIMITER ;
但我不断收到此错误
/* SQL 错误 (1064): 你的 SQL 语法有错误;检查 与您的 MySQL 服务器版本相对应的手册 在“从考试中选择考试类别ID”附近使用的语法 其中考试 ID = the_last_in' 在第 10 行 */
我在语法上使用变量的方式是否正确?
【问题讨论】:
-
尝试在选择查询周围添加括号。
标签: mysql