Joining multiple times to a temporary table
. Getting this error:
Error Code: 1137. Can't reopen table: 'a'
I googled it and found that there is a restriction of some kind on referencing the same temporary table
multiple times in a query. Can anyone explain why this restriction exists?
Here is an exmaple of simple query that will cause this error:
CREATE TEMPORARY TABLE foo
SELECT * FROM shopify_us limit 10;
SELECT *
FROM (
SELECT *
FROM shopify_us
LIMIT 10
) boo
LEFT JOIN foo a ON a.customer_id = boo.customer_id
LEFT JOIN foo b on b.customer_id = boo.customer_id
However, if I simply remove the 2nd join, I no longer encounter the error.