I have the following query in a zip code radius search, but it keeps bombing out on the ROUND and ORDER BY statements. What am I doing wrong?
<cfquery name="getlocs" datasource="zips">
SELECT zipcode, latitude, longitude, state, city,
ROUND((ACos((SIN(#passedzip.latitude#/57.2958) * SIN(latitude/57.2958)) +
(COS(#passedzip.latitude#/57.2958) * COS(latitude/57.2958) *
COS(longitude/57.2958 - #passedzip.longitude#/57.2958))))
* 3963) AS [distance]
FROM ZIPcodes
WHERE latitude >= (#passedzip.latitude# - (#session.passedradius#/111)
And latitude <= #passedzip.latitude# + (#session.passedradius#/111)
AND longitude >= #passedzip.longitude# - (#session.passedradius#/111)
AND longitude <= #passedzip.longitude# + (#session.passedradius#/111)
ORDER BY distance
</cfquery>
Thanks.
<cfquery name="getlocs" datasource="zips">
SELECT zipcode, latitude, longitude, state, city,
ROUND((ACos((SIN(#passedzip.latitude#/57.2958) * SIN(latitude/57.2958)) +
(COS(#passedzip.latitude#/57.2958) * COS(latitude/57.2958) *
COS(longitude/57.2958 - #passedzip.longitude#/57.2958))))
* 3963) AS [distance]
FROM ZIPcodes
WHERE latitude >= (#passedzip.latitude# - (#session.passedradius#/111)
And latitude <= #passedzip.latitude# + (#session.passedradius#/111)
AND longitude >= #passedzip.longitude# - (#session.passedradius#/111)
AND longitude <= #passedzip.longitude# + (#session.passedradius#/111)
ORDER BY distance
</cfquery>
Thanks.