php - How to Find Zip codes by Zip and Distance -
please, me. need find zip codes zip , distance miles. know few ways, how to. can create table location, zip_code, lat, lng , use mysql find can takes many time because,
1 - find lat, lng location.zip_code = xxxx
2 - find mysql -
select `id`, `zip_code`, ( 6373 * acos( cos( radians( :lat ) ) * cos( radians( `lat` ) ) * cos( radians( `long` ) - radians( :long ) ) + sin(radians(:lat)) * sin(radians(`lat`)) ) ) `distance` `location` having `distance` < :distance order `distance` limit 25
return $zip_codes 3 - find sql
select * **** zip in ($zip_codes)
maybe know how optimize case?
Comments
Post a Comment