mysql中三张表建立触发器问题
cazar 2008-01-04 03:39:25 EMS SQL Manager 2007 for MySQL
有三张表 student(student,name),section(section,course,num),enrolls(section,course,student)
要求:当删除student表中的一个学生时,enrolls表中要删除一组数据,同时section表中的num要进行改变
section表中,主码由section和course决定
我建了一个触发器
create trigger students_enrolls_de
after delete on students
for each ROW
begin
delete from enrolls
WHERE student=old.student;
create table a
select enrolls.section,count(enrolls.course) num,enrolls.course
from enrolls,section
where section.course=enrolls.course
and section.section=enrolls.section
group by enrolls.course,enrolls.section;
END;
本来想建立一个新表,然后与section表中的数据产生联系,达到修改num的目的
这是一半代码,显示语法错误,
是不是触发器中不能 建立新表
如果不能,这个问题应该怎样解决
请高手尽快回复,谢谢