mysql存储过程简单案例
数据库  /  管理员 发布于 4年前   405
1.多字段
CREATE DEFINER=`root`@`localhost` PROCEDURE `r404`(a int)
begin
select * from cunzhu ;
SET @count = (select count(*) from cunzhu);
select @count;
select count(*),name,age,home into @count,@name,@age,@home from cunzhu where id=a;
select @count,@name,@age,@home;
end;
call r404(2);
结果:
2.循环查询
CREATE DEFINER=`root`@`localhost` PROCEDURE `r405`()
begin
declare i int default 1;
loop_label: loop
select * from cunzhu where id=i;
set i=i+1;
if i>3 then
leave loop_label;
end if;
end loop;
end;
call r405();
结果:
3.动态拼接
CREATE DEFINER=`root`@`localhost` PROCEDURE `r408`()
begin
set @aa = 'select name from cunzhu where id=2';
set @sentence = concat(@aa);
prepare aa from @sentence;
execute aa;
deallocate prepare aa;
end;
call r408();
结果:
阿凡达123 在
golang 怎么做热更新中评论 也可以看看这个:https://github.com/edwingeng/hot..博主 在
hyperf框架常用命令-在centos7中退出命令及在docker容器中退出命令中评论 @路过的靓仔:cdn静态资源被墙,已修复..GGGGGGGGG 在
layui框架常用输入框介绍中评论 写的很好解决问题..路过的靓仔 在
hyperf框架常用命令-在centos7中退出命令及在docker容器中退出命令中评论 剩下好多 wait 状态的..激光豆芽 在
为什么你不能安逸?国内996为什么没有国外955香?中评论 国内现在无意义的内卷太多了..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号