How do I define the keys for a temporary table that is being created from a SELECT statement?
I have:
CREATE temporary TABLE _temp_unique_parts_trading
engine=memory AS
(SELECT parts_trading.enquiryref,
sellingcurrency,
jobs.id AS jobID
FROM parts_trading,
jobs
WHERE jobs.enquiryref = parts_trading.enquiryref
GROUP BY parts_trading.enquiryref)
But where do I define the keys?
You can do this
CREATE temporary TABLE _temp_unique_parts_trading ( enquiryref varchar(255), sellingcurrency varchar(255), jobID int(10), key(jobId) ) engine=memory AS (SELECT parts_trading.enquiryref, sellingcurrency, jobs.id AS jobID FROM parts_trading, jobs WHERE jobs.enquiryref = parts_trading.enquiryref GROUP BY parts_trading.enquiryref)Basically append the table schema (index, column data type) right after TABLE_NAME