I have a MySQL table of Florists and I'm trying to write a search function which will take Zipcode as an input and find all Florists who deliver to that zipcode. Each florist record in my table has 3 items
- geocoded longitude (centered at the florist's address)
- geocoded latitude (centered at the florist's address)
- a string field of townnames and zipcodes where the florist delivers e.g. - Boston (02215, 02108, 02109), Chelsea (02150), Somerville(02143, 02144, 02145)
Lets say I want to find all florists who deliver to "02108". What is the best way to implement this search in MySQL?
I was thinking
Exact Match search - but this would require every search to scan the entire table. Inefficient?
Haversine search + Exact Match - Use the latitutde/longitude value to narrow down the search to a 15 mile radius
MySQL Great Circle Distance (Haversine formula) And then perform the Exact Match within these results.
Something else?
Would appreciate your thoughts and input.