当前位置:网站首页>MySQL queries nearby data And sort by distance
MySQL queries nearby data And sort by distance
2022-07-02 23:02:00 【Flying husky】
Business background :
Check the public toilets near me , When querying, pass in the longitude of the current user (lng) And latitude (lat), Calculate the location with the toilet information in the database , Get the distance between me and each toilet ( Company : km ), And sort according to the distance , The most recent ones are displayed at the top
SELECT
t1.name,
t1.address,
t1.uid,
t1.code
CONVERT(ACOS(COS(${lat}*PI()/180 )*COS(t1.lat*PI()/180)*COS(${lng}*PI()/180-t1.lng*PI()/180)+SIN(${lat}*PI()/180 )*SIN(t1.lat*PI()/180))*6370996.81/1000, DECIMAL(10,2)) AS distance
FROM
toilet t1
WHERE
t1.is_delete = '0'
ORDER BY
distance ASCThe result of the query :

边栏推荐
- 高并发介绍及应对
- Comprehensively analyze the logic of the shared purchase business model? How sharing purchase empowers Enterprises
- Jatpack------LiveData
- 全面解析分享购商业模式逻辑?分享购是如何赋能企业
- Chow-Liu Tree
- Antd component upload uploads xlsx files and reads the contents of the files
- uniapp微信登录返显用户名和头像
- [LeetCode] 多数元素【169】
- go 4種單例模式
- `Usage of ${}`
猜你喜欢
![[羊城杯2020]easyphp](/img/12/da28f738e50e625b0a66a94af3703d.png)
[羊城杯2020]easyphp

Mask R-CNN
![The kth largest element in the [leetcode] array [215]](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
The kth largest element in the [leetcode] array [215]
![[chestnut sugar GIS] how does global mapper batch produce ground contour lines through DSM](/img/5d/c23ec16df6ce8d78207b635f59dc20.png)
[chestnut sugar GIS] how does global mapper batch produce ground contour lines through DSM

数组进阶提高

World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection

Methods to solve the tampering of Chrome browser and edeg browser homepage

China Academy of information technology, Tsinghua University, Tencent security, cloud native security, industry university research and use strong alliance!

Local dealers play the community group purchase mode and share millions of operations

世界环境日 | 周大福用心服务推动减碳环保
随机推荐
Odoo13 build a hospital HRP environment (detailed steps)
Lambda expression: an article takes you through
[Solved] Splunk: Cannot get username when all users are selected“
分布式监控系统zabbix
手写ORM(对象关系映射)增删改查
Niuke: Dragon and dungeon games
go 条件变量
Jerry's prototype will trigger shutdown after multiple touches [chapter]
How does Jerry test the wrong touch rate of keys [chapter]
uniapp微信登录返显用户名和头像
【板栗糖GIS】global mapper 如何通过dsm批量制作贴地等高线
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
Construction of Hisilicon 3559 universal platform: draw a frame on the captured YUV image
地方经销商玩转社区团购模式,百万运营分享
Jericho's thimble reaction when directly touching the prototype is abnormal [chapter]
go 4種單例模式
Go condition variable
Golang的学习路线
Stop slave is stuck -- the event of the transaction is not copied completely
`Usage of ${}`