前言:除了上次的mysql关联更新之外,删除也可以是关联删除的。
SQL实战:蹩脚的语句如下:
delete unit_detail ud
where ud.unit_id in (
select x.unit_id from unit x where x.fix_flag=5;
);
改进版的关联删除语句:
delete a from unit_detail as a inner join unit as b
where a.unit_id=b.unit_id and b.fix_flag=5;