"SELECT id, lan, lon, name, type, text, ( 6371 * acos( cos( radians('%s') ) * cos( radians( lan ) ) * cos( radians( lon ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lan ) ) ) ) AS distance FROM table HAVING distance < '%s' ORDER BY distance LIMIT 0, 200