where exactly is that first reference, in the outer query or inside the subquery?
Originally Posted by spitfireweb
maybe it would help if we slightly reformatted the query...
the outer query is not aware of any table names used in the subquery
FROM ( SELECT people.*
, (((ACOS(SIN ... ))) AS distance
ON ordnance_survey_locations.postcode = people.postcode
ON counties.id = people.county
WHERE people.archived != '9'
AND people.contract_type = '2') AS dt
WHERE distance <= 20
BY distance ASC
, people.contract_type ASC
, name ASC
, surname ASC