Hi.
How would i go about creating a temporary table containing information retrieved from a previous select statement?
Thanks
Dom
temp tables are created just like regular tables but with the TEMPORARY keyword. then loop thru the previous result set and do an INSERT query on each iteration.
and does the table drop itself automatically? or do i have to do that.
d0m1n1c wrote:and does the table drop itself automatically? or do i have to do that.
yes, it drops itself. that is sort of the whole point of a temp table. you did not mention which RDBMS you are using but i assume it is mySQL. if so read up on the CREATE TABLE Syntax.
ye, mysql.
the table lasts until the connection is closed, right? So if i dont specifially close my session (mysql_close()) then how long will the table last for?
And you make sure you find
CREATE TEMPORARY TABLE foo AS SELECT a, b, c FROM othertable WHERE something
Where Devinemke is pointing you as it's top useful
d0m1n1c wrote:the table lasts until the connection is closed, right? So if i dont specifially close my session (mysql_close()) then how long will the table last for?
the connection will be closed automatically at the end of the script execution.
is it not possible to do
SELECT * INTO TEMPORARY TABLE imatemptable FROM jobs WHERE employer_id = 12
??
dom