mysql组合单个记录中多个记录的数据

时间:2014-06-19 03:31:55

标签: php mysql

我正在研究基于php mysql的学校数据库系统。基本结构如下:

Table Class-Details of all classes.

enter image description here

Table Student-Details of all students

enter image description here

Table Semester-Details of all Semesters

enter image description here

Table class–Semester. This table solves many to many relation, primary key- IDs of both class and semester.

enter image description here

Table Subject -Details of all Subjects

enter image description here

Table class–Subject. This table solves many to many relation, primary key- IDs of both class and semester.

enter image description here

Table marks- consists of student ID, Subject ID, Semester ID, Marks Achieved.Foreign Key ClassID, SemesterID, SubjectID

enter image description here

我试图以下面提到的格式获得一个表格: enter image description here

ENGINE = InnoDB
AUTO_INCREMENT = 53
DEFAULT CHARACTER SET = utf8;

到目前为止,我可以在每个记录中获得单独的主题标记 我的疑问:

SELECT 
                m.MarkID, m.studentID, 
                sm.ExamName, sb.Subject, 
                sm.MaxMarks, m.MarksRecvd  

                FROM marks AS m

                RIGHT JOIN student AS st 
                ON m.studentID=st.studentID

                RIGHT JOIN semester AS sm
                ON m.ExamID=sm.ExamID

                RIGHT JOIN subject AS sb 
                ON m.SubjectID=sb.SubjectID

                WHERE m.studentID = $studentID

请帮我解决这个问题...我正在为每个标记recvd记录如下。

enter image description here

但是我想将所有学期标记分组在一行中,如下所示: enter image description here

朋友请告诉我,如果我的查询是明确的

0 个答案:

没有答案