MYSQL查两个经纬度之间的直线距离,计算出的单位:米

#当前位置经纬度 经度:117.215637   纬度:39.1373367
#表中经纬度字段 经度:longitude    纬度:latitude
select * from(
SELECT id,longitude,latitude, 
ROUND(6378.138*2*ASIN(SQRT(POW(SIN((39.1373367*PI()/180-latitude*PI()/180)/2),2)+COS(39.1373367*PI()/180)*COS(latitude*PI()/180)*POW(SIN((117.215637*PI()/180-longitude*PI()/180)/2),2)))*1000) AS juli
FROM table_name) as tmp_table_name
where juli < 1000
order by juli

  如何查询地址的经纬度:

百度工具:https://api.map.baidu.com/lbsapi/getpoint/index.html

posted @ 2022-02-11 21:39  张志健  阅读(272)  评论(0编辑  收藏  举报