Returning multiple result sets from a MYSQL stored procedure

How do you return multiple result sets from a MYSQL stored procedure?

This is my test stored process:

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

Now when I call it:

 Call test() 

I get only one set of results. How to get both? I am used to MSSQL. I apologize if this is a simple question.

+6
source share
2 answers

You can either try to attach them (tie them together) or use UNION (combine two selections 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

+1
source

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

0
source

Source: https://habr.com/ru/post/897062/


All Articles