mysql 父表触发器删除子表;子表删除触发器更新父表;冲突

begin

#更新house表居住人口数
##判断房子是否还存在
set @house_id=(
	select house_id
	from `house`
	where house_id=old.jumin_house_id
);

if @house_id is not null then
	update `house`
	set house_countjumin=(
		select count(jumin_id)
		from `jumin`
		where jumin_house_id=old.jumin_house_id
	)
	where house_id=old.jumin_house_id;
end if;

end
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章