DELETE语句中指定多个表,根据多个表中的特定条件,从一个表或多个表中删除行。
不过,您不能在一个多表DELETE语句中使用ORDER BY或LIMIT。
DELETE t1, t2 FROM t1, t2, t3 WHERE t1.id=t2.id AND t2.id=t3.id;
如上删除两个两个数据表。
DELETE FROM t1, t2 USING t1, t2, t3 WHERE t1.id=t2.id AND t2.id=t3.id;
delete a, b from a , b where (a.id = b.cat_id) and a.id=?;
使用join删除两个数据表中的数据,如下:
delete a,b from a left join b on a.id = b.cat_id where a.id=6;
当你引用表名时,必须使用引用名如:
delete a,b from category a left join article b on a.id = b.cat_id where a.id=6