MySQL创建多表查询的存储过程的两种方法

来源:互联网 发布:淘宝店铺名字英文名字 编辑:程序博客网 时间:2024/06/05 19:32

成绩表:

科目表:

学生表:

/*<span style="color:#ff0000;">方法一</span>*//*如果该存储过程存在,先删除*/drop PROCEDURE if exists s_stuinfo;
/*创建查询学员信息的有参存储过程*/create procedure s_stuinfo(in stu varchar(10))  select stuNo 学号,stuName 姓名,subjectName 科目,studentResult 成绩,examDate 考试时间 from result,student,subject     where (result.subjectNo = subject.subjectNo and result.studentNo = student.stuNo and student.stuNo = stu);                                                                                       drop PROCEDURE if exists s_stuinfo;create procedure s_stuinfo(in stu varchar(10))  select stuNo 学号,stuName 姓名,subjectName 科目,studentResult 成绩,examDate 考试时间 from result,student,subject     where (result.studentNo = student.stuNo and result.subjectNo = subject.subjectNo and stuNo in (stu));/*调用存储过程*/call s_stuinfo('0305');/*<span style="color:#ff0000;">方法二</span>*/drop procedure if exists ss_stuinfo;create procedure ss_stuinfo(in stu varchar(10))   select stuName 姓名 ,stuNo 学号 ,subjectName 科目,studentResult 成绩,examDate 考试时间 from result      inner join student on result.studentNo = student.stuNo     inner join subject on result.subjectNo = subject.subjectNo        where student.stuNo = stu;call ss_stuinfo('0303');


0 0
原创粉丝点击