现在的位置: 首页php-基础语法>正文
存储过程的使用  
发表于661 天前 php-基础语法 评论数 1
mysql的存储过程的代码中不仅可以执行单条sql语句,也可以执行多条语句和条件语句。

在MySQL的存储过程中执行多条sql语句的语法是:

create procedure proc_name([parameter [, …]])
begin
sql语句

end

MySQL存储过程中的条件语句:

if-then-else,语法如下:

if condition then
       statement1;
else
         statement2;
end if;

MySQL存储过程中的case语句,语法如下:

case variable
when  value1  then statement1;
when  value2   then statement2;

else statement;
end case;

MySQL存储过程中的循环语句:

while,语法如下:

while condition do
statements;
end while;

repeat语句,语法如下:

repeat
statement;
until condition
end while;

loop语句,语法如下:

loop_lebel:phpdo
statements;
if condition then
leave loop_label;           //离开循环
end if;
end loop;

存储过程的使用:目前有1 条留言

  1. 老张 : 2010年07月29日10:32 下午

    其实还有定义变量

不想听你唠叨×