0

I am trying to calculate distance from given Point(lat, long) but when I use an ordering by the distance column I get Commands out of sync; you can't run this command now error.

Here is my query:

SELECT id, name, country_code, postal_code, latitude, longitude, 
    st_distance_sphere(
        point(50.77333, 7.185259), 
        point(latitude, longitude)
    ) AS distance 
FROM place_merged WHERE name LIKE ('ko%') ORDER BY distance

If I remove ORDER BY clause, it executes fine. Is there any way I can calculate distance and get places which are certain distance far from my provided latitude & longitude?

Barmar
  • 741,623
  • 53
  • 500
  • 612
jsan
  • 177
  • 1
  • 2
  • 14

1 Answers1

0

That is in a Stored Procedure, correct? You failed to DEALLOCATE PREPARE.

Rick James
  • 135,179
  • 13
  • 127
  • 222