var req = new { //經度 Longitude = 1, //緯度 Latitude = 1, //跳過條數 offset = 1, //顯示條數 limit = 1, //條件範圍 每增長1搜索範圍差很少增長110km scope = 10, }; string sql = $@"select * from store where 1=1 "; sql = sql + $@"and longitude > ({req.Longitude}-{ req.scope}) and longitude < ({req.Longitude}+{ req.scope}) and latitude > ({req.Latitude}-{ req.scope}) and latitude< ({req.Latitude}+{ req.scope}) order by ACOS(SIN(({req.Latitude} * 3.1415) / 180 ) *SIN((latitude * 3.1415) / 180 ) +COS(({req.Latitude} * 3.1415) / 180 ) * COS((latitude * 3.1415) / 180 ) *COS(({req.Longitude}* 3.1415) / 180 - (longitude * 3.1415) / 180 ) ) * 6380 "; sql = sql + ($@" limit { req.offset},{ req.limit}");