I am trying a query in mysql. I have 3 tables which are linked by the same foriegn key ...
Table 1 = students (PKey - stdnt_rfid_tag)
Table 2 = student_attendance ( FKey - s_id for stdnt_rfid_tag )
Table 3 = users ( Fkey - s_id for stdnt_rfid_tag)
In the students table there is the name of the student which i am interested in.
In the student_attendance table i am interested in the classes attempt.
In the users table i am interested in the course name.
Now I want a query to display the courses which are assigned to the specific users..
Means a student with RFID_TAG = 101 is displayed with 2 courses, so only these two courses should be displayed.
But whenever i run my query it displays the complete list of courses with the assigned users present in the database table. please help..
Here is my query which i have tried.
SELECT s.stdnt_rfid_tag, c.course_name, sa.st_classes_attempt FROM students s INNER JOIN users u ON s.stdnt_rfid_tag = u.st_id INNER JOIN student_attendance sa ON s.stdnt_rfid_tag = sa.st_id INNER JOIN courses c ON sa.c_id = c.course_id