Search code examples
mysqltemp-tables

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


Solution

  • 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.