【发布时间】:2024-01-03 09:13:01
【问题描述】:
如果你有父表
create table parent (
pid int not null,
name varchar(255)
)
还有一个父子连接表
create table parent_child (
pid int not null,
cid int not null,
foreign key (pid) references parent(pid),
foreign key (cid) references child(cid)
)
create table child(
cid int not null,
name varchar(255)
)
我如何在以下列表('dave','henry','myriam','jill')中找到所有孩子的名字的所有父母的名字。
如果父母有一个不同名字的孩子,我不想看到他们,但是如果他们有 1 个或多个孩子并且他们的所有孩子的名字都在列表中,我想看到父母的名字。
我确实找到了这个https://*.com/a/304314/1916621,这将帮助我找到一个拥有这些名字的孩子的父母,但我不知道如何找到那些只有孩子名字在该列表子集中的父母。
如果有人知道不同方法的性能权衡,则加分。
【问题讨论】: