我的表格是这些:
edu_submark :Id,sm_mark,sub_lesson_id,st_id,course_id
edu_mark :Id,ma_mark,ma_midterm,st_id,course_id
edu_sub_lesson :我,sl_title,sl_hour,lesson_id
edu_lesson :Id,le_title,department_id
edu_course :Id,co_title
edu_student :Id,ac_fname,ac_lname
我想要这个结果:
Jack:
active directoy 99
win7 84
winServer 45
Joe:
active directoy 76
win7 NULL
winServer 64
.
.
.
我使用了这个程序,但它只返回一个学生标记:
CREATE PROCEDURE [dbo].[st_select_mark]
@st_id int ,
@course_id int
AS
declare @lesson_id int
set @lesson_id=(SELECT lesson_id FROM edu_course WHERE Id=@course_id)
SELECT
a.sl_title,a.lesson_id,a.Id,b.sm_mark
FROM
edu_sublesson a
LEFT JOIN
edu_submark b on a.Id = b.sub_lesson_id AND b.course_id = @course_id AND b.st_id = @st_id
WHERE
a.lesson_id = @lesson_id
SELECT ma_mark,ma_midterm FROM edu_mark WHERE st_id=@st_id AND course_id=@course_id
RETURN 0