考虑到关系person(name, gender, father, mother)
,以name
为primary key
,并且gender
取值为M
和F
,我如何在sql中编写递归视图以查找提及的列表所有的姐妹们?
假设姐姐的定义意味着父母双方都一样,可以这么简单吗?
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'