我写这个查询是否正确?

时间:2013-12-13 23:41:55

标签: sql

撰写查询以显示学生的fname,lname,courseId,CourseName和学生成绩 R# = R0000123 and CourseId = 11111

课程:

CourseId    SubjectId   Course_Name Title   numOfCredit
11111   CSET    3200    Client Server Architecture  3
11112   CSET    1200    GUI Programming 3

表学生

R_Num   fName   MI  lName   Email
R0000123    Jacob   R   Smith   Jacob.smith@utoledo.edu
R0000124    Frank   K   Jones   Frank.jones@utoledo.edu

表等级

R_Num   CourseId    Grade
R0000123    11111   A
R0000123    11112   B

我写道:

SELECT fName, lName, CourseId, CourseName, Grade
FROM Table Course, Table Students, Table Grade
WHERE R Num = R0000123 AND CourseId = 11111

1 个答案:

答案 0 :(得分:1)

SELECT B.FNAME, B.LNAME, A.COURSEID, C.COURSE_NAME, A.GRADE

FROM TABLE GRADE A 

INNER JOIN TABLE STUDENTS B ON A.R_NUM=B.R_NUM

INNER JOIN TABLE COURSE C ON A.COURSEID=C.COURSEID

WHERE A.R_NUM='0000123' AND A.COURSEID='11111'