-2

I am want to return two tables from one Stored Proc. I am not sure if it is possible or not, but it is possible in MSSQL, so, I guess it is possible in MYSQL as well.

What I want to achieve is:

select * from table1;
select * from table2;

result in dataset of two tables. As I experienced till now, where MYSQL get's the first select it returns from there.

I have tried to find on Google, but I didn't find anything that works.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Ram Singh
  • 6,664
  • 35
  • 100
  • 166

1 Answers1

3

Yes, you can return as many result sets as you like.

delimiter $$
create procedure sp_result_sets()
begin

select * from table1;
select * from table2;

end
$$
slaakso
  • 8,331
  • 2
  • 16
  • 27