mysql的sql语句根据经纬度查询距离排序

SELECT
	id,
s_subbran_name,
	n_longitude,
	n_latitude,

 
	ROUND(
		6378.138 * 2 * ASIN(
			SQRT(
				POW(
					SIN(
						(
							40.042307 * PI() / 180 - n_latitude * PI() / 180
						) / 2
					),
					2
				) + COS(40.042307 * PI() / 180) * COS(n_latitude * PI() / 180) * POW(
					SIN(
						(
							116.317205 * PI() / 180 - 	n_longitude * PI() / 180
						) / 2
					),
					2
				)
			)
		) * 1000
	) AS juli
FROM
subbranch_info
ORDER BY
	juli DESC
 

你可能感兴趣的:(mysql)