I am working on developing a function to detect locations within a specific distance from a waypoint. The distance calculation function is already functional, and I have initiated the process with the query displayed below.
select loc_id from wp where calc_distance(52.15819, 6.40726, wp.lat, wp.lon) <100;
After executing this query, multiple rows are returned. However, when I attempt to count the number of rows using the query below, it does not yield the desired numerical output.
select count(loc_id from wp where calc_distance(52.15819, 6.40726, wp.lat, wp.lon) <100);
I am seeking insights into why this issue may be occurring.
On another note, I am contemplating whether it would be more appropriate to:
- Create this function within MySQL and only call it from a JavaScript file.
- Develop this function within my JavaScript file and access the MySQL table solely when the JavaScript function is invoked.
Thank you in advance.
ABBOV