使用第二个表中的数据从一个表中删除数据

发布于 2025-02-12 08:28:46 字数 103 浏览 0 评论 0原文

我有一个表1,其中有一个百万个数据和一个完全相同的表2,只有106个数据。如何从表1中删除这106个数据? 在这两个表中,我有ID,DATE,PARMAN0,PARAM1,PARAM2等字段。

I have a table table1, where there is a million data and a completely identical table table2, only there are only 106 data. How it is possible to delete these 106 data from table1?
In these two tables i have fields like id, date, param0, param1, param2.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不再见 2025-02-19 08:28:46

假定这两个表中的id列都可以实现这种唯一性,然后:

delete from table1 a
where exists (select null
              from table2 b
              where b.id = a.id
            );

否则,添加更多列(in where 子句),这将帮助您仅删除您真正的行想。

Presuming that uniqueness is enforced through the ID column in both tables, then:

delete from table1 a
where exists (select null
              from table2 b
              where b.id = a.id
            );

Otherwise, add some more columns (into the where clause) which will help you delete only rows you really want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文