Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 用于从表中提取数据的查询_Mysql - Fatal编程技术网

Mysql 用于从表中提取数据的查询

Mysql 用于从表中提取数据的查询,mysql,Mysql,我有以下几张桌子 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(si

我有以下几张桌子

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'

@Manish您看到您的表格主题链接到一个部分,该部分将为我们提供一个部分,而该表格部分未链接到任何其他表格,因此这里似乎有一个死胡同,数据库设计似乎是错误的。

最后,我在没有您帮助的情况下完成了这项工作:/

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

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';

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

@eggyal branch“计算机科学”,sem=3,这是家庭作业吗?您尝试了什么?@tombom正在尝试创建反馈application@Manishtombom在问你试过什么?好吧,这不是家庭作业。但这并不是一个“我们为你工作”的网站。当出现具体问题时,我们会提供帮助,最好是让人们学习一些东西。你不会通过复制和粘贴学到任何东西。这就是为什么我要问的。所以分区和老师也应该绘制地图。我已经创建了教师、学生、部门和学生表以及上面的2个映射表。基于学生的分支、学期和部分,我希望在jsp页面中获取主题和教师,然后学生将给出教师的反馈。反馈将存储在feedbackval表中。