发出反映同一变量的“AS”语句

时间:2014-02-04 05:42:57

标签: php sql distance

在查询期间尝试计算距离时出现问题。 计算“AS距离” 由于某些原因,我的“距离”反映了几个结果的完全相同......当纬度和经度非常不同时。

$result2 = mysqli_query($datacon,"SELECT spreadsheet.*,zipcode, ( 3956 * acos( cos( radians( '$lat_A' ) ) * cos( radians( location_latitude ) ) * cos( radians( location_longitude ) - radians( '$long_A' ) ) + sin( radians( '$lat_A' ) ) * sin( radians( location_latitude ) ) ) ) AS distance

            FROM spreadsheet,craft_zipcodes

            WHERE

            spreadsheet.ZIP=craft_zipcodes.zipcode

            and spreadsheet.package='$package'

            and spreadsheet.HIDE_FROM_SEARCH = '0' and spreadsheet.googlezero = '0'  GROUP BY ADDRESS HAVING distance <= $radius ORDER BY distance asc $pages->limit ");

您可以在此处查看结果: http://carterbackup.revo-tech.com/locations/?package=BOTTLE&radius=5&custzipcode=37419&brand=AMBER&count=19&folder=1&ipp=5

如果您从分页中选择“全部”..您可以看到每20-30行会显示不同的距离?我不知道为什么......

0 个答案:

没有答案