To handle a result set inside a stored procedure, you use a cursor. A cursor allows you to iterate a set of rows returned by a query and process each row individually.
MySQL cursor is read-only, non-scrollable and asensitive (The server may or may not make a copy of its result table).
How to Declare Cursor
DECLARE cursor_name CURSOR FOR SELECT_statement;
How to Open Cursor
FETCH statement to retrieve the next row pointed by the cursor
FETCH cursor_name INTO variables list;
Deactivate the Cursor