-2

我有以下表格

subject(id,name,sem,branch) //Detail of subject in sem and branch
teacher(id,name,dept) //detail of teacher
student_teacher_mapping(sid,tid) //primary key of student and teacher
section(id,sec) //detail of sections
subject_section_mapping(sid,secid) //primary key of subject and section

我想获取分支“计算机科学”的学科名称和教师名称,sem=3 和 section='d'。

4

2 回答 2

0

最后我在没有你帮助的情况下完成了它:/

我换了一张桌子 我的桌子是

subject(id,name,sem,branch) //Detail of subject in sem and branch
teacher(id,name,dept) //detail of teacher
section(id,sec) //detail of sections
sub_teacher_sec (subject_id,teacher_id,section_id) //primary key of subject,teacher and section

这是我获取主题名称、教师姓名和部门以获取特定分支学期和部门值的查询

select sub.name,t.name,se.sec from subjects as sub
  join
sub_teacher_sec as sts
  on
sts.subject_id=sub.id
 join
teachers as t
  on
sts.teacher_id=t.id
 join
section as se
   on
sts.section_id=se.id
and  sub.semester=3 and sub.branch='CSE';

表格或查询中是否有任何更正,请提出建议。

于 2012-09-07T06:59:49.657 回答
0

@Manish你看到你的表SUBJECT链接到SECTION,这会给我们一个SECTION,而表SECTION没有链接到任何其他表,所以这里似乎有死胡同,数据库设计似乎是错误的。

于 2012-09-06T10:03:52.747 回答