1
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?任何這些解決方案?
感謝,