[英]many to many relationship sql
You need to add a foreign key in student and parent that maps back to family_id, Remove parent_id and student_id in the Family table. 您需要在学生和家长中添加一个外键,以映射回family_id,在Family表中删除parent_id和student_id。 If you need to find all member of family 22 如果您需要找到家庭的所有成员22
select * from family f
join parent p on f.family_id=p.family_id
join student s on s.family_id=f.family_id
where f.family_id=22
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.