时间:2021-07-01 10:21:17 帮助过:8人阅读
create procedure p1() begin select * from t_news; end $ //mysql存储过程 简单实例显示存储过程信息: \G (横向表格采用纵向表格输出)
create procedure p2(n int) #含参 begin select * from t_category where cid > n; end $
create procedure p3(n int, j char(1)) #含参 begin if j='h' then #与其他语言不同 必须加then 注意符号= 不是== select * from t_category where cid > n; else select * from t_category where cid
create procedure p4(n smallint) #含参 begin declare i int; declare s int; set s = 0; set i = 1; while i<=n do set s =s+i; set i=i+1; end while; select s; end $