i'm just thinking of your database structure,
Lets think of a situation:
student 1 has 4 grades (comments from the 4 faculty), student 2 hasn't got a grade.
how you will add several grades?
the grades will be mixed after a time.
how you will determine which grades is which ?
Do you want to list that user who hasn't got a grade ?
I can write you a query to select the users and the comments
from the 3 tables, but i think this database model not a good
choice to store grades.
i added a new table, to store the teachers:
Faculties
faculty_id Faculty_name
1 a
2 b
3 c
4 d
This select Lists the users, and counts the faculty's comments. If a user hasn't got a grade this will add a NULL to the faculty_id and countof_grade fields:
SELECT student.student_id, student.first_name, student.last_name, grade.faculty_id, Faculties.Faculty_name, Count(grade.grade_id) AS CountOfgrade_id
FROM (grade RIGHT JOIN student ON grade.student_id = student.student_id) LEFT JOIN Faculties ON grade.faculty_id = Faculties.faculty_id
GROUP BY student.student_id, student.first_name, student.last_name, grade.faculty_id, Faculties.Faculty_name;
If you wanted to list the users - grades - teachers: (those students who hasn't got grades will listed with NULL values in the grades field)
SELECT student.student_id, student.first_name, student.last_name, grade.faculty_id, Faculties.Faculty_name, grade.grade_id, grade.comments
FROM (grade RIGHT JOIN student ON grade.student_id = student.student_id) LEFT JOIN Faculties ON grade.faculty_id = Faculties.faculty_id;
lets test these queries in phpmyadmin to see the results.
hello, jjozsi.