Home > Database > Mysql Tutorial > body text

mysql存储过程如何获取多个结果集

WBOY
Release: 2016-06-06 09:44:42
Original
1487 people have browsed it

mysql多个结果集存储过程 带参数

我想用mysql存储过程获取外键数据,然后通过out输出来。结果发现就能获取一条记录,不知道怎么去获取多条。麻烦各位帮忙看下。

存储过程代码:
CREATE PROCEDURE empCusState( in riqi date,out rname varchar(2000),out cname varchar(2000),out tname varchar(2000))
begin

declare 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;

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template