Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
MySQL POINT spatial index query within radius from center POINT

I see many solutions for getting the nearest rows from a POINT to convert to X() and Y() and do trig calculations of distances... As I understand, this does not seem to take advantage of the spatial index?

How do you take advantage of the spatial index, in the most common sense of, returning rows whose spatial POINT is within a radius from a center POINT?

In other words, how do you get something like this - where LatLng is the lat lng location stored as POINT for each row, and CenterPoint the epicenter

Pseudocode query: SELECT * FROM geotable WHERE d=Distance(LatLng,CenterPoint) < 10 ORDER by d

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use st_distance_sphere

SELECT * 
FROM geotable 
WHERE st_distance_sphere(POINT(-82.337036, 29.645095 ), POINT(`longitude`, `latitude` ))/1000  < 10

Here you can see a working example

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!