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