创建一个触发器
语法:create trigger 触发器名字create trigger xiaoshou_update_trigger
after update on xiaoshou
for each row
begin
update jiangjin
set xiaoshouer=(
select sum(taoshu*danjia)from xiaoshou
where userid=new.userid
and month=new.month) ,
jiangjin=(select sum(taoshu*xiaoshou.danjia*ticheng)
from house,xiaoshou
where userid=new.userid
and month=new.month and houseid=id)
where userid=new.userid
and month=new.month;delete from
jiangjin where xiaoshouer<500;
delete from jiangjin where xiaoshouer<500;
end
原文:http://sunsai.blog.51cto.com/9044695/1426487