views:

52

answers:

2

Hi folks! I'm trying to use temp tables to speed up my MySQL 4.1.22-standard database and what seems like a simple operation is causing me all kinds of issues. My code is below....

CREATE TEMPORARY TABLE nonDerivativeTransaction_temp (
   accession_number varchar(30), 
   transactionDateValue date)
) TYPE=HEAP;

INSERT INTO nonDerivativeTransaction_temp 
VALUES( SELECT accession_number, transactionDateValue 
          FROM nonDerivativeTransaction 
         WHERE transactionDateValue = "2010-06-15");

SELECT * 
  FROM nonDerivativeTransaction_temp;

The original table (nonDerivativeTransaction) has two fields, accession_number (varchar(30)) and transactionDateValue (date).

Apparently I am getting an issue with the first two statements but I can't seem to nail down what it is. Any help would be appreciated.

+1  A: 

Drop the VALUES( in INSERT INTO ... VALUES ( SELECT, it's either VALUES() or SELECT, not both.

And normally this setup of yours would slow down things rather then speed them up unless you're querying the temporary table a LOT during the session, and query-caching is off and/or not feasible.

Wrikken
Thanks Wrikken. The original table has a TON of entries and I only need a given date at any particular time. My solution was to use a temp table to hold only those values of that particular date.
AmyD
+1: It's a syntax error. @AmyD: When in doubt, have a look at the documentation: http://dev.mysql.com/doc/refman/5.1/en/insert.html
OMG Ponies
A: 

A quick look makes me wonder if the mismatched parens might be part of your problem...

mickeyf
Holy crap! I can't believe I boned this on a such a simple mistake as a parens.
AmyD