公式以下,單位米: 第一點經緯度:lng1 lat1 第二點經緯度:lng2 lat2 round(6378.138*2*asin(sqrt(pow(sin((lat1*pi()/180-lat2*pi()/180)/2),2)+cos(lat1*pi()/180)*cos(lat2*pi()/180)*pow(sin( (lng1*pi()/180-lng2*pi()/180)/2),2)))*1000)
git
SELECT store_id, lng, lat, ROUND( 6378.138 * 2 * ASIN( SQRT( POW( SIN( ( 22.299439 * PI() / 180 - lat * PI() / 180 ) / 2 ), 2 ) + COS(22.299439 * PI() / 180) * COS(lat * PI() / 180) * POW( SIN( ( 114.173881 * PI() / 180 - lng * PI() / 180 ) / 2 ), 2 ) ) ) * 1000 ) AS juli FROM store_info HAVING juli > 500 ORDER BY juli DESC LIMIT 100
SELECT id,address, longitude, latitude, ROUND( 6378.138 * 2 * ASIN( SQRT( POW( SIN( ( 36.6528865730 * PI() / 180 - latitude * PI() / 180 ) / 2 ), 2 ) + COS(36.6528865730 * PI() / 180) * COS(latitude * PI() / 180) * POW( SIN( ( 117.0733427689 * PI() / 180 - longitude * PI() / 180 ) / 2 ), 2 ) ) ) * 1000 ) AS juli FROM eleme_shops ORDER BY juli