我有四张桌子
student
-------
id, int
firstName, varchar
lastName, varchar
course
------
id, int
name, varchar
semester
--------
id, int
name, varchar
mark
----
studentId, int
courseId, int
semesterId, int
mark, int
我想创建一个sql查询,为{{1}中的每一行重新firstName
,lastName
,courseName
,semesterName
和mark
} table。
我尝试使用INNER JOIN进行此操作,但我无法为多个表创建INNER JOIN。
我最终达成的代码
mark
答案 0 :(得分:1)
在Ms Ms中,您必须在具有多个联接的查询中包括括号:
select st.firstName, st.lastName, c.name, sm.name, m.mark
from (((mark m
INNER JOIN student st ON st.id = m.studentId)
INNER JOIN course c ON c.id = m.courseId)
INNER JOIN semester sm ON sm.id = m.semesterId)
答案 1 :(得分:1)
尝试使用theta style join:
select student.firstName, student.lastName, course.name, semester.name, mark.mark
from mark, student ,course, semester
WHERE student.id = mark.studentId AND course.id = mark.courseId AND semester.id = mark.semesterId