如何两表关联来删除其中一个表的记录?
delete a
inner join b on b.id=a.id and b.xx=1
DELETE FROM a where exists (select 1 from b where b.id=a.id and b.xx=1 )
本文介绍了一种通过两表关联来进行记录删除的方法。使用 SQL 的 DELETE 语句结合 INNER JOIN,可以根据关联条件从一个表中删除对应记录。这种方式适用于需要根据另一个表中的状态来决定是否删除的情况。
如何两表关联来删除其中一个表的记录?
delete a
inner join b on b.id=a.id and b.xx=1
DELETE FROM a where exists (select 1 from b where b.id=a.id and b.xx=1 )
6867

被折叠的 条评论
为什么被折叠?