To store a temporary result set you can use a special type of table i.e. called MySQL temporary table. To keep temporary data, the temporary tables could be very useful in some cases. When the current client session terminates, the temporary tables is deleted.
This is useful for stored procedures, join query etc. Temporary tables were added in MySQL version 3.23.
Example of MySQL temporary table creation:
CREATE TEMPORARY TABLE temp_user SELECT * FROM user u INNER JOIN result r ON u.user_id = r.user_id GROUP BY u.user_id;
Read Also: MySQL GROUP_CONCAT() maximum length
Now you can query data from temp_user table by following query:
SELECT * FROM temp_user;
After completing the functionality you can delete the temporary table using:
DROP TEMPORARY TABLE temp_user;