Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to design a pivot table from MySQL
    primarykey
    data
    text
    <p>I have tried alot to accomplish this to no success, so im here for help. I will try to give full details so i can help myself get the best needed solution. </p> <p>from my MySQL Database</p> <pre><code>Table (students) -------------------------------- studentID | class_id | and other info Table (class) ------------------------------- classID | name | other info Table (subjects) -------------------------------- subjectID | name | class_id (references Class.classID) Table (exam_type) -------------------------------- exam_typeID | name | desc | start_date Table (result) --------------------------------------------- student_id | exam_type_id | subject_id | mark </code></pre> <p>In my query i have this:</p> <pre><code>SELECT subjects.name, exam_type.name, result.mark FROM subjects LEFT JOIN result ON result.subject_id=subjects.subjectID JOIN exam_type ON exam_type.exam_typeID=result.exam_type_id WHERE result.student_id=$x ORDER BY subjects.name, exam_type.name </code></pre> <p>In the query $x is the id of the student to show his/her result</p> <p>the query returns this</p> <p><img src="https://i.stack.imgur.com/sQV57.png" alt="results shown, from dummy data in my database"></p> <p>Pretty much to this level i am okay now my headache is i want to displace the result in such a way...see my design already.</p> <p><img src="https://i.stack.imgur.com/npUJ1.png" alt="front end"></p> <p>its going to be really helpful if somebody point me to the right direction to diplace the info in the first picture as such.</p> <pre><code>---------------------------------------------- CA Tests | Exams ----------------------------------------------- subjects | 1 | 2 | 3 | score ----------------------------------------------- Agricultural science | 10 | 9 | 8 | 56 ----------------------------------------------- English language | 12 | 13 | 12 | 43 ----------------------------------------------- French Language | 11 | | | </code></pre> <p><strong>SOLVED:</strong> by JIML's solution <img src="https://i.stack.imgur.com/m1GEg.png" alt="solved"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload