开发者

How to retrieve all rows thats co-ords are within a specifc radius in MySql Database

开发者 https://www.devze.com 2023-03-14 00:22 出处:网络
i am looking for a select statement that when given a specific set of co-ords(lng1+lat1) it will return a开发者_C百科ll the rows within a 1km radius of lng1+lat1? this is to work with a mysql server?

i am looking for a select statement that when given a specific set of co-ords(lng1+lat1) it will return a开发者_C百科ll the rows within a 1km radius of lng1+lat1? this is to work with a mysql server?

      |_id_|_lat_|lng_|
row 1 | 1  | 1.3 |5.3 |
row 2 | 2  | 1.3 |5.2 |
row 3 | 3  | 2.3 |5.9 |


select * from table where POW((_lat_-lat1),2) + POW((_lng_-lng1),2) < 1 
0

精彩评论

暂无评论...
验证码 换一张
取 消