当前位置:网站首页>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;边栏推荐
- Demo of converting point cloud coordinates to world coordinates
- Traversal before, during and after binary tree
- Use ffmpeg command line to push UDP and RTP streams (H264 and TS), and ffplay receives
- Bean configuration override in boot
- Usage of group by
- 使用 percona 工具给 MySQL 表加字段中断后该如何操作
- mysql 计算经纬度范围内的数据
- Pattern matching extraction of specific subgraphs in graphx graph Computing Practice
- Fastjson list to jsonarray and jsonarray to list "suggested collections"
- 手机app通达信添加自定义公式(分时T+0)为例子讲解
猜你喜欢

手机app通达信添加自定义公式(分时T+0)为例子讲解

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

动态规划入门一,队列的bfs(70.121.279.200)

动态规划入门二(5.647.62)

Idea public method extraction shortcut key

Experiment collection of University "Fundamentals of circuit analysis". Experiment 7 - Research on sinusoidal steady-state circuit

基于 Nebula Graph 构建百亿关系知识图谱实践

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

全是精华的模电专题复习资料:基本放大电路知识点

《大学“电路分析基础”课程实验合集.实验七》丨正弦稳态电路的研究
随机推荐
Comparison between rstan Bayesian regression model and standard linear regression model of R language MCMC
Group by的用法
Some problems about pytorch extension
idea jar包冲突排查
Fiddler实现手机抓包——入门
仙人掌之歌——投石问路(2)
6091. Divide the array so that the maximum difference is K
/Bin/ld: cannot find -lgssapi_ krb5
The task cannot be submitted after the installation of flick is completed
How to use percona tool to add fields to MySQL table after interruption
手机app通达信添加自定义公式(分时T+0)为例子讲解
【题解】Educational Codeforces Round 82
/bin/ld: 找不到 -lssl
Pyinstaller打包exe附带图片的方法
2278. Percentage of letters in string
Application of visualization technology in Nebula graph
[2. Basics of Delphi grammar] 3 Object Pascal constants and variables
GraphX 图计算实践之模式匹配抽取特定子图
SQL FOREIGN KEY
Bean configuration override in boot