删除没有关联记录的记录

发布于 2024-09-03 19:23:24 字数 106 浏览 5 评论 0原文

我在 postgreSQL 数据库中有一个“客人”表和“邀请”表,它们与多对一关系绑定。我已经删除了一些来宾,现在我想删除没有来宾的邀请。我尝试使用“COUNT”,但 WHERE 子句中不允许聚合。

I have a 'guests' table and 'invitations' table bound with many-to-one relationship in a postgreSQL database. I have removed some guests and now I want to remove invitations that have no guests. I tried using 'COUNT', but aggregates are not allowed in WHERE clause.

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

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

发布评论

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

评论(1

走走停停 2024-09-10 19:23:24

检查一下:

delete from invitations where invitationid 
not in (select invitationid from guests)

Check this :

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