简体   繁体   中英

How to use a mysql stored procedure result set in another stored procedure

I want to filter the result set returned by a stored procedure in side another stored procedure

Ex:

delimiter //
create procedure x()
begin
select 1 as a, 2 as b,3 as c;
end //

In y stored procedure I want to select only 'a' column value return from 'x' stored procedure

delimiter //
create procedure y()
begin

end// 

Maybe this will help.

First get result from proc x into a temporary table tmp :

            delimiter //
            create procedure x()
            begin
            create temporary table `tmp`
            select 1 as a, 2 as b,3 as c;
            end //

then call proc x into proc y

            delimiter //
            create procedure y()
            begin
            call x();
            select a from tmp;
            end //

Finally call y() to result the field a from proc x select .

If you want to get only proc x result then run:

            call x();
            select * from tmp;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM