Categories: MySQL

MySQL temporary table

Share

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;

Recent Posts

Warm Comfort: Choosing the Best Hot Water Bottle for Cozy Nights

Introduction: As the chill of winter settles in or a bout of cold weather strikes,…

2 hours ago

One Location, Different Perspectives: The Allure of Dubai Marina Apartments

Nestled along the glittering waterfront of the City of Gold, Dubai Marina beckons to discerning…

2 hours ago

Role Of Gojek Clone In Growth Campaigns For Your Business

When was the last time you heard that a clone app like Gojek could efficiently…

8 hours ago

How to Optimize Your E-Commerce Pages and Improve UX?

The e-commerce market is growing and evolving at a rapid pace. More and more people…

19 hours ago

Overview of Reputation, Services, and Features of IplWin

IplWin stands as a reliable and enthralling platform for Indian punters, offering a captivating blend…

3 days ago

Blogging Brilliance: Driving Traffic and Engagement with Quality Content

Introduction In today's online age, consumers are constantly bombarded with information. They crave valuable content…

3 days ago