【发布时间】:2016-08-31 03:08:20
【问题描述】:
student table teacher table sports table parents table
--------- -------------- ------------ ---------------
id name id name id name id stud_id fathername mothername
------------ ------------ ------------ -----------------------------------------
1 S1 1 T1 1 SP1 1 1 xxxxxx yyyyyyy
2 S2 2 T2 2 SP2 2 2 abc aaa
3 S3 3 T3 3 SP3
student_teacher table student_sports table
id stud_id teacher_id id sutd_id sports_id
------------------------------ ------------------------------
1 1 1 1 1 1
2 1 2 2 1 2
3 1 3 3 1 3
4 2 2 4 3 2
5 2 3 5 3 3
如何编写查询以从所有表中获取学生 S1 的信息。 例如,学生 S1 参加的运动名称、教授学生 S1 的老师姓名、学生 S1 家长信息。这里学生、教师、父表中的 id 是主键。 stud_id、teacher_id、sports_id 是外键,指的是学生、教师、运动表的主键。 请帮我从表中获取学生 S1 的记录。提前致谢。
【问题讨论】: