好的,所以我有一组表,我正在尝试创建一个语句,该语句将返回某个员工教授的模块名称。我知道联接是附加这些表以便我可以查询它们的最有效方式。
职员
+---------+-------------+-----------------+
|Staff Id |Staff Name |Grade |
+---------+-------------+-----------------+
|E10010 |Alan Turing |Senior Lecturer |
|E10011 |Tony Hoare |Reader |
|E10012 |Seymour Cray |Lecturer |
+---------+-------------+-----------------+
教
+---------+-----------+
|Staff Id | Module Id |
+---------+-----------+
|E10010 |CS101 |
|E10011 |CS203 |
|E10012 |CS204 |
|E10010 |CS204 |
|E10011 |M101 |
|E10011 |CS101 |
+---------+-----------+
模块
+----------+-------------------------------+-------+
|Module Id |Module Name |Credits|
+----------+-------------------------------+-------+
|CS101 |Introduction to Computing |10 |
|CS203 |Data Structures and Algorithms |10 |
|CS204 |Computer Architecture |10 |
|M101 |Mathematics I |20 |
+----------+-------------------------------+-------+
本质上,我想要一个看起来像这样的查询:
SELECT Module Name FROM Staff, Teaches, Module WHERE Staff Id = 'E10010';
这将返回 Alan Turing 教授的模块的所有模块名称:
+--------------------------+
|Introduction to Computing |
|Computer Architecture |
+--------------------------+
我知道该语句没有以正确的方式加入字段,并且我需要使用 JOIN 语句,但不确定如何继续。如果有人可以解释这一点,那就太好了。提前干杯!