This is a query to find the search radius of a zip code within a certain parameter. The input to be entered from a form with a dropdown menu and text box. I would like to do is replace the "50" with a variable from the
pulldown menu (2, 5, 10, 20, or 50) and the zipcode "27017" with the zip
code itself from the form field.
round(
((1.852 * 60.0 * ((acos(sin(zc2.rlat) * sin(zc1.rlat) + cos(zc2.rlat)
* cos(zc1.rlat) * cos(abs( (zc1.rlong)-(zc2.rlong) )) )/pi())*180)) /
1.609344),2)
as Distance
from ZipCode zc1, ZipCode zc2
where
zc2.zip = '27017'
and
((1.852 * 60.0 * ((acos(sin(zc2.rlat) * sin(zc1.rlat) + cos(zc2.rlat)
* cos(zc1.rlat) * cos(abs( (zc1.rlong)-(zc2.rlong) )) )/pi())*180)) /
1.609344) <= 50
and zc1.zip not like '27017'
order by
((1.852 * 60.0 * ((acos(sin(zc2.rlat) * sin(zc1.rlat) + cos(zc2.rlat)
* cos(zc1.rlat) * cos(abs( (zc1.rlong)-(zc2.rlong) )) )/pi())*180)) /
1.609344)
Thank you,
Greg
pulldown menu (2, 5, 10, 20, or 50) and the zipcode "27017" with the zip
code itself from the form field.
round(
((1.852 * 60.0 * ((acos(sin(zc2.rlat) * sin(zc1.rlat) + cos(zc2.rlat)
* cos(zc1.rlat) * cos(abs( (zc1.rlong)-(zc2.rlong) )) )/pi())*180)) /
1.609344),2)
as Distance
from ZipCode zc1, ZipCode zc2
where
zc2.zip = '27017'
and
((1.852 * 60.0 * ((acos(sin(zc2.rlat) * sin(zc1.rlat) + cos(zc2.rlat)
* cos(zc1.rlat) * cos(abs( (zc1.rlong)-(zc2.rlong) )) )/pi())*180)) /
1.609344) <= 50
and zc1.zip not like '27017'
order by
((1.852 * 60.0 * ((acos(sin(zc2.rlat) * sin(zc1.rlat) + cos(zc2.rlat)
* cos(zc1.rlat) * cos(abs( (zc1.rlong)-(zc2.rlong) )) )/pi())*180)) /
1.609344)
Thank you,
Greg