Du vil gerne bruge en underforespørgsel:
select wp_id
from (select cl.wp_id,( 3959 * acos( cos( radians(12.91841) ) * cos( radians( y(gproperty) ) ) *
cos( radians( x(gproperty)) - radians(77.58631) ) + sin( radians(12.91841) ) *
sin( radians(y(gproperty) ) ) ) ) AS distance
from db1.geofeature gf join
db2.c_loc cl
on gf.o_type = 256 and cl.c_info_id = 146 and gf.o_id = cl.wp_id
) t
where distance < 10
order by distance
limit 10;
Bemærk, at jeg også rettede joinsyntaksen til at bruge eksplicitte joinforbindelser.