我现在有两张表A,B,两张表有外键关联,现在我想使用mysql的存储结构删除A表(关联B表)的数据,怎么写啊
------解决思路----------------------
除了使用级联删除外,还可以使用临时表删除:
Select *
into #tmpAB
from A AS a
JOIN B as b on a.id=b.id;
Delete from A
where exists(select 1 from #tmpAB where #tmpAB.id=A.id);
Delete from B
where exists(select 1 from #tmpAB where #tmpAB.id=B.id);