MySQL stored procedures can use SELECT statements in their body,
returning a data set to the caller. The manual also explains that multiple data sets can
be returned from such a stored procedure.
For example, assume you have this stored procedure:
CREATE PROCEDURE p1(x INT, y INT)
DETERMINISTIC
BEGIN
SELECT
x ;
SELECT
x AS first_param,
y AS second_param;
SELECT
x,
y,
x + y AS sum_xy,
x * y AS prod_xy;
SELECT * FROM t1;
END
There are four SELECT statements, with different headers, and a
variable number of rows returned.
Early versions of …