using a mysql temporary table.
| From: | Jeff Bearer | Date: | Mon, 25 Feb 2002 15:34:12 +0000 |
| Subject: | using a mysql temporary table. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-86096@lists.php.net to get a copy of this message | ||
Hello,
I'm trying to use a temporary table in mySQL with PHP. First I tried to
create a temporary table and then query it in the same script. But the
table didn't persist to the second query in the PHP script.
I found this knowledge base entry:
http://www.faqts.com/knowledge_base/view.phtml/aid/445
Where it shows to do all the querying in one swoop. The problem I'm
having now is that PHP is throwing an error at the first semi-colon. It
appears that it doesn't want to run multiple query statements in 1 query
function.
I'm using the mySQL pear class in my application, I wouldn't think that
it would have any effect on the problem.
Here is an example of the query I'm attempting.
CREATE TEMPORARY TABLE tmp_events SELECT event_id, event_title FROM
events; INSERT INTO tmp_events SELECT event_id, event_title FROM
special_events; SELECT event_id, event_title FROM tmp_events ORDER BY
event_title;
But I get an error like:
1064: You have an error in your SQL syntax near '; INSERT INTO
tmp_events'
If I echo my SQL statement and paste it into mySQL the query works fine.
Any suggestions that you can offer would be great.
--
Jeff Bearer, RHCE
Webmaster
PittsburghLIVE.com
2002 EPpy Award, Best Online U.S. Newspaper