当前位置:网站首页>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;边栏推荐
- 隐藏在 Nebula Graph 背后的星辰大海
- Fastjson list to jsonarray and jsonarray to list "suggested collections"
- Ant group's large-scale map computing system tugraph passed the national evaluation
- Floyed "suggestions collection"
- Ssh/scp does not prompt all activities are monitored and reported
- 构建多架构镜像的最佳实践
- /bin/ld: 找不到 -lgssapi_krb5
- Wise target detection 23 - pytoch builds SSD target detection platform
- Pyinstaller's method of packaging pictures attached to exe
- 图数据库|Nebula Graph v3.1.0 性能报告
猜你喜欢

《大学“电路分析基础”课程实验合集.实验五》丨线性有源二端网络等效电路的研究

Ant group's large-scale map computing system tugraph passed the national evaluation

Experiment collection of University Course "Fundamentals of circuit analysis". Experiment 5 - Research on equivalent circuit of linear active two terminal network

如何實現十億級離線 CSV 導入 Nebula Graph

XPT2046 四线电阻式触摸屏

The outline dimension function application of small motherboard

PostgresSQL 流复制 主备切换 主库无读写宕机场景

Armv8-a programming guide MMU (4)

Introduction to dynamic planning I, BFS of queue (70.121.279.200)

Huawei ECS installs mysqlb for mysqld service failed because the control process exited with error code. See “sys
随机推荐
如何实现十亿级离线 CSV 导入 Nebula Graph
Boot transaction usage
Boot 连接 Impala数据库
《大学“电路分析基础”课程实验合集.实验六》丨典型信号的观察与测量
智联招聘的基于 Nebula Graph 的推荐实践分享
Boot 事务使用
Flink real-time data warehouse (7): Flink realizes the full pull module to extract data in MySQL
手机app通达信添加自定义公式(分时T+0)为例子讲解
Huawei ECS installs mysqlb for mysqld service failed because the control process exited with error code. See “sys
Bean configuration override in boot
Soul torture, what is AQS???
/bin/ld: 找不到 -lxslt
将点云坐标转换成世界坐标的demo
Locate: cannot execute stat() `/var/lib/mlocate/mlocate Db ': there is no such file or directory
Pyinstaller打包exe附带图片的方法
Moveit obstacle avoidance path planning demo
Application of visualization technology in Nebula graph
数据库系统概论第一章简答题-期末考得怎么样?
6095. Strong password checker II
全方位解读服务网格(Service Mesh)的背景和概念