Hacker News new | past | comments | ask | show | jobs | submit login

Download the database I posted in my other comment here, and try this SQL statement:

   SELECT z.ZIPcode, (sqrt((z.latitude-z2.latitude)*(z.latitude-z2.latitude)+(z.longtitude-z2.longtitude)*(z.longtitude-z2.longtitude)))) AS dist
   FROM `zip` AS `z`, `zip` AS `z2`
   WHERE `z2`.`ZIPcode = 'YOURZIPCODE'
   ORDER BY dist LIMIT 10
Might be faster if you do a query to get the lat and long for the ZIP code you need first, though. Hell, it would probably be fastest to skip the database all together and just import the data and loop the distance formula, recording the smallest distances as you go.



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: