SQL. temp table vs new query?

Is it safe and a good practice to create temp table process the request and then drop table appose to simply creating a new query request call?

DROP TABLE IF EXISTS tablea.MyTempTable;
CREATE TABLE tablea.MyTempTable (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

Insert Into tablea.MyTempTable(id)

SELECT ............

DROP TABLE IF EXISTS tablea.MyTempTable;

I need 2 queries to fetch data and a third one to order by date!

NOPE can’t join those tables since they share no relevance only store similar data.

No. Consider two requests coming it at the same time, let’s call them A and B:

A: DROP TABLE
A: CREATE TABLE
A: FILL TABLE
B: DROP TABLE
B: CREATE TABLE
A: USE TABLE

A will find the table empty (or if B got futher it might even find data for another request!!)

sorry, no

Hmmm. This smells to me. How about posting your DB schema for us to review. I have never come across a DB on the help forums that did not have a design problem.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.