wemustdesign Posted July 22, 2011 Share Posted July 22, 2011 Hi, I am using this query to list the closest distances to a certain lat/ lon $qry = "SELECT *,(((acos(sin(($lat*pi()/180)) * sin((`lat`*pi()/180))+cos(($lat*pi()/180)) * cos((`lat`*pi()/180)) * cos((($lon- `lon`)*pi()/180))))*180/pi())*60*1.1515) AS distance FROM `location` WHERE distance <= 10"; I am getting an error: Unknown column 'distance' in 'where clause' Can anybody see what the error is? Link to comment https://forums.phpfreaks.com/topic/242638-distance-query/ Share on other sites More sharing options...
premiso Posted July 22, 2011 Share Posted July 22, 2011 Sounds like you have an unknown column called distance inside of your where clause. So either your table columns are mis-named or you wrote the wrong column name in your where clause. Link to comment https://forums.phpfreaks.com/topic/242638-distance-query/#findComment-1246180 Share on other sites More sharing options...
wemustdesign Posted July 22, 2011 Author Share Posted July 22, 2011 I know I do not have a distance column, I am using the calculation as distance AS distance FROM `location` WHERE distance < Link to comment https://forums.phpfreaks.com/topic/242638-distance-query/#findComment-1246181 Share on other sites More sharing options...
wemustdesign Posted July 22, 2011 Author Share Posted July 22, 2011 Solved: Changed WHERE to HAVING Link to comment https://forums.phpfreaks.com/topic/242638-distance-query/#findComment-1246185 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.