我有四个这样的表: 表1:考试
-----------+--------------+---------
examID | examName | session |
-----------+--------------+---------
表2:课程
-----------+--------------+---------
courseID | title | credit |
-----------+--------------+---------
表3:审查员
-------------+----------+-------------+------------+--------+
examinerID | examID | teacherID | courseID | part |
-------------+----------+-------------+------------+--------+
1 | 1 | 3 | 5 | A or B |
-------------+----------+-------------+------------+--------+
表4:标记
---------+--------------+-------------+-----------+------
markID | examinerID | studentID | courseID | mark |
---------+--------------+-------------+-----------+------
我想对这些表运行一些查询,以便它根据examID生成php数组的课程表格,如下所示: -
$marks['courseID'] = array(
'course' => array(),//array of course details
'part_a_mark'=> array(),// array of marks of part A of that courseID
'part_B_mark'=> array(),// array of marks of part B of that courseID
);
答案 0 :(得分:1)
使用SQL语句无法直接获得预期的输出。您需要在php循环语句中处理查询结果,然后遍历结果来形成数组。