I have two tables namely student and subject joined by a table called student_subject.
With the following structure
student:
+----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+----------------+
| student_ID | int(11) | NO | PRI | NULL | auto_increment |
| studentCode | varchar(8) | NO | | NULL | |
| studentName | varchar(255) | NO | | NULL | |
| studentType | varchar(50) | NO | | NULL | |
| visaIssueDate | date | YES | | NULL | |
| visaExpiryDate | date | YES | | NULL | |
| parentID | int(11) | YES | MUL | NULL | |
+----------------+--------------+------+-----+---------+----------------+
subject:
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| code | varchar(255) | NO | | NULL | |
| name | varchar(255) | NO | | NULL | |
| department | varchar(255) | NO | | NULL | |
+------------+--------------+------+-----+---------+----------------+
student_subject:
+-----------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| studentID | int(11) | NO | MUL | NULL | |
| subjectID | int(11) | NO | MUL | NULL | |
| grade | char(2) | YES | | NULL | |
+-----------+---------+------+-----+---------+----------------+
I want to query all the subjects for a particular student using the field student.student_ID. How do i go about doing that?
Thanks.