当前位置:网站首页>MySQL calculates the data within the longitude and latitude range
MySQL calculates the data within the longitude and latitude range
2022-07-02 15:58:00 【Please tell him】
Using Google solutions
The SQL statement that will find the closest 20 locations that are within a radius of 30 miles to the 78.3232, 65.3234 coordinate. It calculates the distance based on the latitude/longitude of that row and the target latitude/longitude, and then asks for only rows where the distance value is less than 30 miles, orders the whole query by distance, and limits it to 20 results. To search by kilometers instead of miles, replace 3959 with 6371.
Example :( Google )
SELECT
id, (
3959 * acos (
cos ( radians(78.3232) )
* cos( radians( lat ) )
* cos( radians( lng ) - radians(65.3234) )
+ sin ( radians(78.3232) )
* sin( radians( lat ) )
)
) AS distance
FROM markers
HAVING distance < 30
ORDER BY distance
LIMIT 0 , 20; These are Google instructions , The following is translated by Google 
According to the above description , There are the following application examples
among
3959 Is miles of the radius of the earth ,6371 Is the kilometer of the radius of the earth ,LATITUDE Is the longitude of the database field ,LONGITUDE Is the latitude of the database ,18.7777 Is the longitude of the search ,55.3774 Is the latitude of the search, that is (18.7777,55.3774) This position is a little Search the neighborhood 3.7KM The location data of
SELECT
id, (
3959 * acos (
cos ( radians(18.7777) )
* cos( radians( LATITUDE) )
* cos( radians( LONGITUDE) - radians(55.3774) )
+ sin ( radians(18.7777) )
* sin( radians( LATITUDE) )
)
) AS distance
FROM markers
HAVING distance < 3700
ORDER BY distance
LIMIT 0 , 20;边栏推荐
- Crawl the information of national colleges and universities in 1 minute and make it into a large screen for visualization!
- 注册成为harmonyos开发者并安装DevEco Studio 3.0 Beta2 for HarmonyOS
- Analysis of the difference between array and linked list
- ssh/scp 使不提示 All activities are monitored and reported.
- /bin/ld: 找不到 -lxml2
- Fiddler实现手机抓包——入门
- Invalid bound statement (not found) solution summary
- Make p12 certificate [easy to understand]
- Demo of converting point cloud coordinates to world coordinates
- Moveit 避障路径规划 demo
猜你喜欢

中科大脑知识图谱平台建设及业务实践

Comparison between rstan Bayesian regression model and standard linear regression model of R language MCMC

处理gzip: stdin: not in gzip formattar: Child returned status 1tar: Error is not recoverable: exitin

《大学“电路分析基础”课程实验合集.实验四》丨线性电路特性的研究

手机app通达信添加自定义公式(分时T+0)为例子讲解
![[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)](/img/26/3f19d36c048e669c736e27384e0fa7.jpg)
[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)

注册成为harmonyos开发者并安装DevEco Studio 3.0 Beta2 for HarmonyOS

愛可可AI前沿推介(7.2)

Postgressql stream replication active / standby switchover primary database no read / write downtime scenario

Application of visualization technology in Nebula graph
随机推荐
/bin/ld: 找不到 -lgssapi_krb5
[solution] educational codeforces round 82
仙人掌之歌——投石问路(3)
Fiddler realizes mobile packet capturing - getting started
/Bin/ld: cannot find -lxslt
Huawei ECS installs mysqlb for mysqld service failed because the control process exited with error code. See “sys
Flink real-time data warehouse (IX): incremental synchronization of data in MySQL
Tree binary search tree
Aike AI frontier promotion (7.2)
Pattern matching extraction of specific subgraphs in graphx graph Computing Practice
Song of cactus - throwing stones to ask the way (2)
Golang MD5 encryption and MD5 salt value encryption
Invalid bound statement (not found)解决方法总结
floyed「建议收藏」
二叉树前,中,后序遍历
解决** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the defau
Comment réaliser un graphique Nebula d'importation CSV hors ligne de niveau milliard
Analysis of the difference between array and linked list
制作p12证书[通俗易懂]
SQL modification statement