1

I found a sample of code

SELECT *
FROM locator
WHERE SQRT(POW(X(center) - 49.843317 , 2) + POW(Y(center) - 24.026642, 2)) * 100 < radius

in this question Find points within a distance using MySQL.

How can I add an ORDER BY distance to this code?

2
  • 1
    Will this answer your question ORDER BY SQRT(POW(X(center) - 49.843317 , 2) + POW(Y(center) - 24.026642, 2)) * 100?
    – Taras
    Apr 1, 2020 at 15:27
  • Yep! Works like a dream! Thank you Taras!
    – runback
    Apr 17, 2020 at 15:04

1 Answer 1

2

Please change your query as following

SELECT *
FROM locator
WHERE SQRT(POW(X(center) - 49.843317, 2) + POW(Y(center) - 24.026642, 2)) * 100 < radius
ORDER BY SQRT(POW(X(center) - 49.843317, 2) + POW(Y(center) - 24.026642, 2)) * 100

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.