开发者

Return Multiple Result Sets from MYSQL Stored Procedure

开发者 https://www.devze.com 2023-04-04 04:53 出处:网络
How do you return multiple result sets from a MYSQL Stored Procedure? This is my test stored proc: DELIMITER $$

How do you return multiple result sets from a MYSQL Stored Procedure?

This is my test stored proc:

DELIMITER $$

CREATE DEFINER=`hlamAdmin`@`%` PROCEDURE `test`()
BEGIN
   SELECT *
   FROM hlam.member;

   SELECT * 
   FROM hlam.secu开发者_如何学运维rity;

END

Now when I call this:

Call test()

I only receive one resultset. How do I receive both? I am used to MSSQL I apologize if this is an easy question.


You could try to either JOIN them (Linking them together) or use UNION (Combine two selects in one);

http://dev.mysql.com/doc/refman/5.0/en/join.html

select a.col1, b.col1
from table1 a
inner join table2 b on a.id = b.id;

http://dev.mysql.com/doc/refman/5.0/en/union.html

select name as col1, surname as col2 from table1
union
select location as col1, desc as col2 from table2;

John


Using HeidiSQL (free MySQL client), I get both resultsets, but on two different tabs.

0

精彩评论

暂无评论...
验证码 换一张
取 消