Mysql 通过经纬度计算与其他多条经纬度的距离


单位:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
set  @lng = 116.315145;  #经度
set  @lat = 40.049026;   #纬度
 
SELECT
     lng,
     lat,
     ROUND(
         6378.138 * 2 * ASIN(
             SQRT(
                 POW(
                     SIN(
                         (
                             @lat * PI() / 180 - lat * PI() / 180
                         ) / 2
                     ),
                     2
                 ) + COS(40.049026 * PI() / 180) * COS(lat * PI() / 180) * POW(
                     SIN(
                         (
                             @lng * PI() / 180 - lng * PI() / 180
                         ) / 2
                     ),
                     2
                 )
             )
         ) * 1000
     AS  juli
FROM
     yr_shop


你可能感兴趣的:(Mysql 通过经纬度计算与其他多条经纬度的距离)