テーブル
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
私のクエリ:
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
結果:
firstname lastname Section Name Subject
John Smith Section A English
私の質問は、そのインストラクターのジョン・スミスが数学の科目も教えているとしたら、それをどのように照会するのでしょうか? 新しい subject_id を追加する必要がありますか? これらの解決策はありますか?
ありがとう、