Mysql使用存储过程,删除表数据

我现在有两张表A,B,两张表有外键关联,现在我想使用mysql的存储结构删除A表(关联B表)的数据,怎么写啊

http://blog.163.com/zsq303288862@126/blog/static/93745961201218112633563/
http://blog.163.com/liujun_wangyi/blog/static/110281637200922642314721/

参考
http://blog.csdn.net/mqboss/article/details/5873455

 delete from b where b.aid in (select id from a);
delete from a;

如果a表和b表有关联,需要先删除子表b的数据,然后再删除a的数据,sql如下:

delete from b where exists( select 1 from a where id = b.id);

delete from a;