Table
Instructor
------------------------------------------------------
| id | firstname | lastname | subject_id | section_id |
------------------------------------------------------
1 John Smith 1 1
Subject
-------------
| id | name |
-------------
1 English
2 Math
Section
-------------
| id | name |
-------------
1 Section A
My Query:
SELECT ins.firstname, ins.lastname,sec.name as "Section Name", sub.name as "Subject"
FROM instructor as ins
JOIN section as sec
JOIN subject as sub
WHERE ins.section_id = sec.id AND ins.subject_id = sub.id AND ins.id =1
Result:
firstname lastname Section Name Subject
John Smith Section A English
My question is what if that instructor john smith also teaching Math subject how I am going to query that? Do I need to add new subject_id? Any solution for these?
Thanks,
you can add another table used for storing the subjects for each instructor, ex