Hi!
>>>>> "Philip" == Philip Lijnzaad <lijnzaad@stripped> writes:
Philip> On Wed, 25 Apr 2001 17:45:12 +0300 (EEST),
Philip> "Sinisa" == Sinisa Milivojevic <sinisa@stripped> wrote:
Sinisa> Philip Lijnzaad writes:
>>> When doing a cumulation:
>>>
>>> select d1.n, d1.cnt, sum(d2.cnt*d2.n) as cum
>>> from distro d1, distro d2
>>> where d1.n >= d2.n
>>> group by d1.n, d1.cnt
>>> order by d1.n;
>>>
>>> this works fine if distro is an ordinary table, but not if distro is a
>>> TEMPORARY one. In that case, I get a message
>>>
>>> Can't reopen table: 'd1'
<cut>
Sinisa> The above is not a bug.
Philip> Well ... it's at least a strange inconsistency. Common sense, nor the
Philip> documentation, nor the error message suggest that you can not have a table
Philip> alias for temporary tables. As a result, I spent an hour or so getting a
Philip> tricky query right. So it may not be a programming error, but it's certainly
Philip> something that could (and should) be improved.
Alias is not the problem; The problem is using the same temporary table twice
in the same query. (The current design makes this a bit hard to do)
This problem is actually documented. You can find this at:
http://www.mysql.com/doc/B/u/Bugs.html
Regards,
Monty