问题描述
- mysql存储过程如何获取多个结果集
-
我想用mysql存储过程获取外键数据,然后通过out输出来。结果发现就能获取一条记录,不知道怎么去获取多条。麻烦各位帮忙看下。存储过程代码:
CREATE PROCEDURE empCusState( in riqi date,out rname varchar(2000),out cname varchar(2000),out tname varchar(2000))
begindeclare sql_text varchar(5000);
set sql_text = concat('select t.t_Name , r.r_Name , c.c_Name into @sql_tname, @sql_rname,@sql_cname from
((roomcourse rc inner join teacher t on rc.t_Id=t.t_Id ) inner join room r on rc.r_Id=r.r_Id) inner join course c on rc.c_Id=c.c_Id where rc.rc_dates='',riqi,''');set @sql_text = sql_text;
prepare stmt from @sql_text;
execute stmt;
set rname = @sql_rname;
set cname = @sql_cname;
set tname = @sql_tname;
end
执行代码:
call empCusState('2014-03-03',@a,@b,@c);
select @a,@b,@c;
时间: 2024-12-02 23:41:50