Possible Duplicate:
how to find 20 closest points efficiently
How to find points, sort them based on closeness, and get 1-20, 21-40, etc. Efficiently using Myisam and mysql
Actually I want to find N closest points.
However, I learn that such thing don't exist in mysql myisam. I asked quesetions here no answer.
So I'll follow people's advice to search for points in a rectangle and then keep expanding the rectangle till I got enough points.
How would I do so? What would be the exact mysql command to do so?
I think I will make PhP loop. If possible, it'll be great if the loop is inside the mysql command itself.
Steps I already took: 1. I already add spatial extension. 2. I already ask around if, given that I have the spatial extension, I can easily get N nearest neighbors for myIsam mysql. I do NOT find ANY answer that works for mySQL myISam spatial index. Some says such answer do not exist because mysql is late comer.
how to find 20 closest points efficiently
So please don't put comment like "you can add spatial extension." That's like starting from the beginning. I know. It's listed on the question I linked.
Actually it's a good comment because it remind me I didn't mention what I went through before asking.
I wouldn't have asked this question if adding spatial extension worked easily.
In short I wouldn't have asked anything until I am really stuck and have searched for this for hours.
Again I ALREADY have spatial indexes. I wouldn't be in GIS if I don't even know what spatial index is.
Now I want actual mysql command to take advantage of that so called spatial index.