SELECT distance FROM table WHERE distance < ( SELECT MAX(distance)/2 FROM table)
The key part was the subquery. They came back and said it returned an error:
"Can't reopen table"
The problem is this was on a TEMPORARY table. The manual clearly states this as a restriction:
You cannot refer to a
TEMPORARYtable more than once in the same query. (http://dev.mysql.com/doc/refman/5.0/en/temporary-table-problems.html)
However I decided to do a bit of digging to find out why that's the case. So I found a nicely commented answer, straight from the source's mouth:
We're trying to use the same temporary table twice in a query.
Right now we don't support this because a temporary table
is always represented by only one TABLE object in THD, and
it can not be cloned. Emit an error for an unsupported behavior
*/ from sql/sql_base.cc open_table