创建存储过程
create procedure 名称(in|out|inout 名称 类型,...)
begin
过程体;
end
说明:
过程体中可以使用我们学过的所有SQL
可以用变量,运算,流程控制器语句,函数,
存储过程没有返回值
声明变量
declare maxAge int;
mysql中赋值声明变量
set @num = 100;
eg:
delimiter //改编SQL语句的结束符
新建一个存储过程,用来根据班级id,查询班级的人数
create procedure getStudentNum(in classidn int)
begin
select count(*) as num from student where classid = classidn;
end;
call getStudentNum(5)
运算
and or not
赋值
set 变量=值