CREATEDEFINER=`root`@`localhost`PROCEDURE`mypro`()BEGINselect student.sno,sname,cname,grade
from student,sc,course
where student.sno=sc.sno and sc.cno=course.cno;END
调用存储过程
call mypro()
2、创建一个存储过程,知道学号,查询选课信息
CREATEDEFINER=`root`@`localhost`PROCEDURE`myprosno`(in s varchar(20))BEGINselect*from sc
where sno=s;END
调用存储过程
call myprosno('1227')
3、创建一个存储过程,知道姓名,查询学生选课信息信息
CREATEDEFINER=`root`@`localhost`PROCEDURE`myprosname`(in sn varchar(20))BEGINselect student.sno,sname,cname,grade
from student,sc,course
where student.sno=sc.sno and sc.cno=course.cno and sname=sn;END
调用存储过程
call myprosname('李佳')
4、创建一个存储过程,知道姓名和课程名,查询学生的选课信息
CREATEDEFINER=`root`@`localhost`PROCEDURE`myprosnamecname`(in sn varchar(20),cn varchar(20))BEGINselect student.sno,sname,cname,grade
from student,sc,course
where student.sno=sc.sno and sc.cno=course.cno and sname=sn and cname=cn;END
调用存储过程
call myprosnamecname('李佳','数学')