Hello!
I have read some posts here, but couldn't find the answer to my problem.
I am working on motorbike company page and i'm developing some temproary solution for so called "dealer locator".
The problem is that it (also) works with US zip codes and since there are many (around 30000) my queryes are pretty much slow!
I have two tables:
DEALERS
- id
- name, address,....
- zip
ZIPS
- id
- zip
- state (e.g. CO)
- full name of state (Connecticut)
- longitude
- latitude
- ... (two more)
My query looks something like this:
SELECT zip, abs(latitude-$latitude)....... AS distance FROM zips,dealers WHERE zip.id = dealers.zip ORDER BY distance
(THIS IS NOT EXACTLY THE CODE! I made it up right now, because i cannot connect to the f****** server or my computer at work. The point is that the syntax is correct)
Everything is OK just that this works very slow.
Would it make a difference if i'd make another table just with longitude,latitude (with which i calculate distance between states) and then select other informations (like zip code, state, full name of the state,...)?
Thank you everyone so much!
Lenart