I'm using following sql code to find out 'ALL' poi closest to the set coordinates, but I would want to find out specific poi instead of all of them. When I try to use the where clause I get an error and it doesn't work and this is where I'm currently stuck, since I only use one table for all the coordinates off all poi's.
SET @orig_lat=55.4058;
SET @orig_lon=13.7907;
SET @dist=10;
SELECT
*,
3956 * 2 * ASIN(SQRT(POWER(SIN((@orig_lat -abs(latitude)) * pi()/180 / 2), 2)
+ COS(@orig_lat * pi()/180 ) * COS(abs(latitude) * pi()/180)
* POWER(SIN((@orig_lon - longitude) * pi()/180 / 2), 2) )) as distance
FROM geo_kulplex.sweden_bobo
HAVING distance < @dist
ORDER BY distance limit 10;
See Question&Answers more detail:os