简体   繁体   English

如何在另一个存储过程中使用mysql存储过程结果集

[英]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 在y存储过程中,我只想选择从“ x”存储过程返回的“ a”列值

delimiter //
create procedure y()
begin

end// 

Maybe this will help. 也许这会有所帮助。

First get result from proc x into a temporary table tmp : 首先从proc x获取结果到临时表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 然后将proc x调用为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 . 最后调用y()以从proc x select中得到字段a。

If you want to get only proc x result then run: 如果只想获取proc x结果,请运行:

            call x();
            select * from tmp;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在另一个存储过程中使用mysql存储过程的结果集 - use result set of mysql stored procedure in another stored procedure mysql:如何将存储过程的结果用作另一个存储过程中的表/视图 - mysql: how to use the result of a stored procedure as a table/view in another stored procedure 存储过程的循环结果集 - loop result set of MySQL Stored Procedure 如何获得存储过程结果集到其他存储过程。 或在MySQL中的函数中返回表 - How to get stored procedure result set to other stored procedure. Or return table in function in MySQL MySQL-嵌套存储过程的使用结果 - MySQL - use result of nested stored procedure 如何从mysql中的另一个存储过程调用存储过程? - How to call a Stored Procedure from another Stored Procedure in mysql? 如何获取存储过程结果以用于另一个存储过程或查询语句 - how do i get a stored procedure result to use on another stored procedure or query statement Mysql存储过程:如何处理空结果集 - Mysql Stored Procedure: how to handle empty result set 如何从laravel的mysql存储过程中获取多个结果集 - how to fetch multiple result set from a mysql stored procedure in laravel 如何在Trigger MYSQL中将变量设置为存储过程的结果? - How to set a variable to the result of a stored procedure inside a Trigger MYSQL?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM