I have a USPS zip code table that shows zip, city, state, latitude, and longitude. I hope to allow a person to enter a zip code to find other locations near them. While I can play around with formulas of latitude and longitude for proximity searches, I want to keep things simple by searching a range of zip codes (which are typically adjacent).
If I am searching for 10 zipcodes on either side of '64430', I could do...
But this does not guarantee 10 results on either side of the zip code of 64430 since there is no zipcode of 64425. Can someone suggest the ideal SQL?
If I am searching for 10 zipcodes on either side of '64430', I could do...
Code:
SELECT *
FROM zipcodes
WHERE zipcodes.zip >= 64420
AND zipcodes.zip <= 64440;
But this does not guarantee 10 results on either side of the zip code of 64430 since there is no zipcode of 64425. Can someone suggest the ideal SQL?