查询递归视图

问题描述 投票:0回答:1

考虑到关系person(name, gender, father, mother),以nameprimary key,并且gender取值为MF,我如何在中编写递归视图以查找提及的列表所有的姐妹们?

sql recursive-query
1个回答
0
投票

假设姐姐的定义意味着父母双方都一样,可以这么简单吗?

select t2.name
from table t1 join table t2 on t1.mother = t2mother
and t1.father = t2.father

where t1.name <> t2.name
and t2.gender = 'F'
© www.soinside.com 2019 - 2024. All rights reserved.