mysql关联表删除数据

有时候我们需要删除表中部分内容,或删除一个表中在另一个表中已经存在的内容,可以用以下方法:

1、delete from t1 where 条件;

2、delete t1 from t1, t2 where 条件;

3、delete t1, t2 from t1, t2 where 条件;

 

eg:

删除表t1已经在表t2中存在的数据:

DELETE t1 FROM table_1 t1, table_2 t2
WHERE t1.id=t2.id and t1.year=t2.year and t1.month=t2.month;
posted @ 2019-08-18 13:52  justfighting  阅读(17605)  评论(0)    收藏  举报