下面是我穿件存儲過程的代碼。求大神幫忙看看。真心很急,明天就要用。
create procedure searchStudentGrade(in id char)
begin
if id is null
select student.StudentID,student.StudentName,student.ClassNumber,grade.ExamID,course.CourseName,grade.Grade,course.CourseID
from student,grade,course
where student.StudentID=grade.StudentID and grade.CourseID=course.CourseID;
else
select student.StudentID,student.StudentName,student.ClassNumber,grade.ExamID,course.CourseName,grade.Grade,course.CourseID
from student,grade,course
where student.StudentID=grade.StudentID and grade.CourseID=course.CourseID and grade.StudentID=id;
end if;
end;
create procedure searchStudentGrade(in id char)
begin
if id is null then 這裡少了一個then吧
select student.StudentID,student.StudentName,student.ClassNumber,grade.ExamID,course.CourseName,grade.Grade,course.CourseID
from student,grade,course
where student.StudentID=grade.StudentID and grade.CourseID=course.CourseID;
else
select student.StudentID,student.StudentName,student.ClassNumber,grade.ExamID,course.CourseName,grade.Grade,course.CourseID
from student,grade,course
where student.StudentID=grade.StudentID and grade.CourseID=course.CourseID and grade.StudentID=id;
end if;
end;