gpt4 book ai didi

mysql - 删除第二个表中的行

转载 作者:行者123 更新时间:2023-11-29 02:30:50 25 4
gpt4 key购买 nike

我想知道是否有人可以帮助我我有两个表 1) profile 2) mailbox_conversation每个表都有一个名为 profile_id 的公共(public)列

我想在个人资料表中找到 membership_id = 107 的所有成员(即获取成员资格类型为 107 的成员的子集,他们将按 profile_id 在数组中列出)然后使用该成员子集,在表 mailbox_conversation 中找到该子集中具有 profile_id 的所有对话 - 因此许多电子邮件可能具有相同的 profile_id,我希望将它们全部删除

最佳答案

查找与 membership_id = 107 的个人资料对应的电子邮件

select m.id
from mailbox_conversation m
join profile p on p.profile_id = m.profile_id
and p.membership_id = 107

删除那些记录

delete from mailbox_conversation
using mailbox_conversation, profile
where profile.profile_id = mailbox_conversation.profile_id
and profile.membership_id = 107;

SQL Fiddle玩。

关于mysql - 删除第二个表中的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13442543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com