#1.两点距离(1.4142135623730951)
select st_distance(point(0,0),point(1,1));
select st_distance(point (120.10591, 30.30163),point(120.13026,30.25961)) as distance HAVING distance>0 ORDER BY distance;
mysql 5.6 添加
#2.两点球面距离(157249.0357231545m)
select st_distance_sphere(point(0,0),point(1,1)) as distance HAVING distance>0 ORDER BY distance;
select st_distance_sphere(point (120.10591, 30.30163),point(120.13026,30.25961)) as distance HAVING distance>0 ORDER BY distance;
This function was added in MySQL 5.7.6.
第一个函数是计算平面坐标系下,两点的距离,就是
如果用于计算地球两点的距离,带入的参数是角度