计算记录

时间:2012-11-03 09:59:34

标签: php mysql

如何计算此查询中的记录,这些记录满足条件距离。请帮助:)

"SELECT
    ( 6371 * acos( cos( radians({$dane['lat']}) ) * cos( radians(o.lat ) ) * cos( radians(o.lng ) - radians({$dane['lng']}) ) + sin( radians({$dane['lat']}) ) * sin( radians(o.lat ) ) ) ) AS distance
,COUNT(*)
FROM ogloszenia o
$where
GROUP BY o.id
HAVING distance<$promien"

1 个答案:

答案 0 :(得分:0)

"SELECT
        ( 6371 * acos( cos( radians({$dane['lat']}) ) * cos( radians(o.lat ) ) * cos( radians(o.lng ) - radians({$dane['lng']}) ) + sin( radians({$dane['lat']}) ) * sin( radians(o.lat ) ) ) ) AS distance
,COUNT(*)
FROM ogloszeniao
where
GROUP BY o.id
HAVING distance<" . $promien . " "