- 同时删除两个表的数据(没有外键)
DELETE t1,t2 FROM t1,t2 WHERE t1.id = :ID and t1.id = t2.t1_id
- 删除脏数据(删除表1中的数据->表2中不存在的)
delete FROM t1 WHERE NOT exists(SELECT c1,c2 FROM t2 as b WHERE t1.id=t2.t1_id)
DELETE t1,t2 FROM t1,t2 WHERE t1.id = :ID and t1.id = t2.t1_id
delete FROM t1 WHERE NOT exists(SELECT c1,c2 FROM t2 as b WHERE t1.id=t2.t1_id)
本文标题:sql语句
本文链接:https://www.haomeiwen.com/subject/qxrdqqtx.html
网友评论