Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Temporary Tables Not Working in PHPMyAdmin

I run this query

CREATE TEMPORARY TABLE usercount SELECT * FROM users

I get this message

Your SQL query has been executed successfully ( Query took 0.1471 sec )

But when I try to access the newly created table using

SELECT * FROM usercount

I get this error

#1146 - Table 'abc_site.usercount' doesn't exist

Not sure why, I need to mention that I've did a good share of googling beforehand.

My version of PHPMyAdmin is 3.5.2.2 and MySQL 5.5.27

like image 581
cristi _b Avatar asked Jan 20 '13 16:01

cristi _b


People also ask

How do I JOIN a temp table in MySQL?

In this example, we are going to create a temporary table whose structure is based on the already available tables in the database. Here, the structure of a temporary table is created by using the SELECT statement and merge two tables using the INNER JOIN clause and sorts them based on the price.

Can we use temporary table in MySQL?

You can use the TEMPORARY keyword when creating a table. A TEMPORARY table is visible only within the current session, and is dropped automatically when the session is closed.

Do you have to manually delete temporary tables?

The use of temporary tables, or temp tables in SQL terms, is common in SQL, but once we're done with those tables, they should be deleted, or dropped. Using the DROP TABLE command on a temporary table, as with any table, will delete the table and remove all data.


1 Answers

PHPMyAdmin (or rather PHP) closes the database connection after each screen. Thus your temporary tables disappear.

You can put multiple SQL statements in the SQL query box in PHPMyAdmin; this should be executed as one block and thus the temporary table is not deleted.

like image 57
JvO Avatar answered Oct 16 '22 15:10

JvO