日期:2014-05-16  浏览次数:20712 次

mysql多表删除 快点 再快点....
有表 A B C D E F G

SQL code
A.id = B.aid = C.aid = D.aid = E.aid = F.aid = G.aid


现在要把id为1的数据在所有表中全部删除

刚开始写的循环删除 但执行效率太慢了

有没有更好的办法使效率更高

------解决方案--------------------
DELETE A,B,C,D,E,F,G FROM A,B,C,D,E,F,G WHERE 
A.id = B.aid 
and
A.id= C.aid 
and
A.id= D.aid
 and
A.id= E.aid 
and
A.id= F.aid
and
A.id = G.aid
------解决方案--------------------
DELETE A,B,C,D,E,F,G FROM A,B,C,D,E,F,G WHERE
A.id = B.aid
and
A.id= C.aid
and
A.id= D.aid
 and
A.id= E.aid
and
A.id= F.aid
and
A.id = G.aid 
and A.id=1;
------解决方案--------------------
DELETE A,B,C,D,E,F,G 
FROM A,B,C,D,E,F,G 
WHERE A.id = 1
and B.aid =1
and C.aid = 1
and D.aid = 1
and E.aid = 1
and F.aid = 1
and G.aid = 1