mysqli - Duplicate Temporary Table MySQL -


i want reference temporary table multiple times in same query. due problem temporary tables cannot that:

http://dev.mysql.com/doc/refman/5.7/en/temporary-table-problems.html

so fix i'm creating duplicates of temporary table:

create temporary table if not exists earnings_temp_one (select * earnings earning_account_id = ?); create temporary table if not exists earnings_temp_two (select * earnings earning_account_id = ?); create temporary table if not exists earnings_temp_three (select * earnings earning_account_id = ?); 

but requires me query massive table earnings 3 times, extent defeats purpose.

is there way me duplicate temporary table, under different name?

then run query on massive table once.

or maybe there's fix temporary table problem doesn't require me create duplicates?

ok, solved it:

create temporary table if not exists earnings_temp_one (select * earnings earning_account_id = ?); create temporary table if not exists earnings_temp_two (select * earnings_temp_one); create temporary table if not exists earnings_temp_three (select * earnings_temp_one); 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -