您好,欢迎来到刀刀网。
搜索
您的当前位置:首页mysql搜寻附近N公里内数据的实例

mysql搜寻附近N公里内数据的实例

来源:刀刀网


根据计算公式得到查询语句如下:

select * from `location` where (
acos(sin(([#latitude#]*3.1415)/180) * sin((latitude*3.1415)/180) + cos(([#latitude#]*3.1415)/180) * cos((latitude*3.1415)/180) * cos(([#longitude#]*3.1415)/180 - (longitude*3.1415)/180))*6370.996)<=1;

执行查询:

mysql> select * from `location` where ( -> acos( -> sin((23.1436*3.1415)/180) * sin((latitude*3.1415)/180) + -> cos((23.1436*3.1415)/180) * cos((latitude*3.1415)/180) * cos((113.323568*3.1415)/180 - (longitude*3.1415)/180) -> )*6370.996 -> )<=1;
+----+-----------+----------------+---------------+| id | name | longitude | latitude |
+----+-----------+----------------+---------------+| 2 | 林和西 | 113.3306110000 | 23.1472340000 |
+----+-----------+----------------+---------------+

本文讲解了mysql 搜寻附近N公里内数据的实例相关内容,更多相关知识请关注Gxl网。

相关推荐:
mysql 连接闪断自动重连的方法

php 实现HTML实体编号与非ASCII字符串相互转换类

php 根据自增id创建唯一编号类

Copyright © 2019- gamedaodao.com 版权所有 湘ICP备2022005869号-6

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务