我在mysql中有以下查询
SELECT id,
(SELECT ( 6371 * Acos(Cos(Radians('31.502537032937294')) *
Cos(Radians(lat)) *
Cos(
Radians(lng) - Radians(
'74.34226725250483'))
+
Sin(
Radians('31.502537032937294')) *
Sin(Radians(lat))) ) AS distance
FROM `addresses`
WHERE orders.id = addresses.order_id
AND `type` = 'from'
AND `address_for` = 'order'
AND `is_archive` = 0
HAVING `distance` <= 50) AS distance
FROM orders
WHERE `is_archive` = 0
AND `is_complete` = 0
AND `status_id` = 1
AND Date(`expected_pick_up_at`) = '2018-09-10'
其中,我正在计算到当前位置的订单距离。该查询的结果如下
id distance
1027 3.392817926161619
1028 2.957290773676651
实际距离为
id distance
1027 0.09565605656865
1028 0.43565656101560
我用来计算距离的数据库中保存的原始经纬度为
id lat long
1027 31.53189017798653 74.35203921049833
1028 31.52842855342999 74.34939790517092
任何人都可以指导我在这方面做错了什么
注意:我还查看了以下question