桌子
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吗?这些有什么解决办法吗?
谢谢,