
Originally Posted by
spitfireweb
That makes sense but, why does it not fail during the first reference to a column within the people table?
where exactly is that first reference, in the outer query or inside the subquery?

maybe it would help if we slightly reformatted the query...
Code:
SELECT *
FROM ( SELECT people.*
, (((ACOS(SIN ... ))) AS distance
FROM people
LEFT
JOIN ordnance_survey_locations
ON ordnance_survey_locations.postcode = people.postcode
LEFT
JOIN counties
ON counties.id = people.county
WHERE people.archived != '9'
AND people.contract_type = '2') AS dt
WHERE distance <= 20
ORDER
BY distance ASC
, people.contract_type ASC
, name ASC
, surname ASC
LIMIT 0,50
the outer query is not aware of any table names used in the subquery
Bookmarks