mysql 查询半径范围内经纬度坐标
当前经纬度:#{startLatitude},#{startLongitude}
半径范围:#{radius}
地球半径:111195
单位:米
st_distance 计算的结果单位是度,需要乘111195(地球半径6371000*PI/180)是将值转化为米。
SELECTt.name,t.start_longitude,t.start_latitude,( st_distance ( point ( t.start_longitude, t.start_latitude ), point ( #{startLatitude},#{startLongitude} ) ) * 111195 ) AS distance
FROMkws_trip t
HAVINGdistance < #{radius}
ORDER BYdistance
<select id="selectTripListByKeywords" parameterType="com.woodare.tsp.app.kawasaki.pojo.knt.request.SearchTripListRequest" resultType="com.woodare.tsp.app.kawasaki.domain.Trip">SELECTtrip.app_user_account_uid,trip.app_username,trip.device_uid,trip.device_name,trip.name,trip.start_latitude,trip.start_longitude,trip.start_address,trip.start_time,trip.end_latitude,trip.end_longitude,trip.end_address,trip.end_time,trip.avg_speed,trip.total_time,trip.total_distance,trip.score,trip.is_favorite,trip.images,trip.is_from_share,trip.from_share_app_user_account_uid,trip.from_share_time,trip.uid,trip.create_by,trip.create_time,trip.visible_type,trip.like_count,trip.trim_image_url,trip.suface_type,trip.weather,trip.keywords,trip.trip_start_idx,trip.trip_end_idx,trip.first_name,trip.last_name,trip.avatar,trip.model_name,trip.device_photo,trip.is_local<if test="radius != null">, ( st_distance ( point ( trip.start_longitude, trip.start_latitude ), point ( #{startLongitude},#{startLatitude} ) ) * 111195 ) AS distance</if>fromkws_trip tripwheretrip.is_deleted=0 and trip.visible_type != 2<if test="keywords != null and keywords != ''">and (trip.keywords like CONCAT('%',#{keywords},'%')or trip.name like CONCAT('%',#{keywords},'%')or trip.start_address like CONCAT('%',#{keywords},'%')or trip.end_address like CONCAT('%',#{keywords},'%'))</if><if test="productUid != null and productUid != ''">and trip.product_uid = #{productUid}</if><if test="startDate != null and endDate != null"><![CDATA[ and trip.start_time >= #{startDate} and trip.end_time < #{endDate} ]]></if><if test="radius != null">HAVING<![CDATA[ distance < #{radius} ]]>ORDER BYdistance</if><if test="radius == null">order by trip.create_time desc</if></select>
参考:
https://www.cnblogs.com/dw3306/p/16612011.html
mysql 查询半径范围内经纬度坐标相关推荐
- php按选定日期查询,php mysql查询指定范围内日期
摘要 腾兴网为您分享:php mysql查询指定范围内日期,掌上新华,掌上公交,学习帮,喜马拉雅等软件知识,以及mts,97漫画网,三菱plc编程软件win10,零点八,2016考研国家线,生化奇兵补 ...
- MySQL查询7天内过生日的用户 查询生日是今天的用户 解决跨年问题
MySQL查询生日是今天的用户 select * from customer where MONTH(birthday) = MONTH(NOW()) and DAY(birthday) = DAY( ...
- [已解决]mysql查询一周内的数据,解决一周的起始日期是从星期日(星期天|周日|周天)开始的问题
前言 今天又遇到很坑的问题了,因为外国友人每一周的起始日期是周日,跟我们的不一样,我们每一周的起始日期是星期一,这样导致我要用mysql统计一周的数据的时候,对于我们来说,查询的记录包括:上周日的记录 ...
- mysql 查询1小时内_mysql查询一个小时之内的数据
由于项目的需要经常查询一个小时之内的数据,接下来吾爱编程为大家分享一下使用Mysql查询一个小时之内的数据的sql,有需要的小伙伴可以参考一下: 1.方法一: (1).sql写法: SELECT * ...
- MYSQL 查询指定范围内的经纬度
select * from `location` where ( acos( sin(([#latitude#]*3.1415)/180) * sin((latitude*3.1415)/180) + ...
- mysql查询10分钟内的数据库_十分钟了结MySQL information_schema
information_schema数据库是MySQL系统自带的数据库,它提供了数据库元数据的访问方式.感觉information_schema就像是MySQL实例的一个百科全书,记录了数据库当中大部 ...
- mysql查询一天内,一周,一个月内的消费记录
查询一天: select * from 表名 where to_days(时间字段名) = to_days(now()); select * from 表名 where date(时间字段名) = c ...
- mysql查询一周内数据并分组_mysql 统计本周7天的数据并分组
今天写到项目的一个数据展示模块,最终要呈现的效果是用柱状图显示本周七天的访客数量,所以要给前端本周7天的数据 比如今天是周二(实际上也是),我们要给前端周一周二的数据,后面周三到周日因为还没到,数据置 ...
- mysql查询5分钟内的数据
查询sql语句: select * from tb_log where createtime>=DATE_SUB(NOW(),INTERVAL 5 MINUTE); DATE函数扩展: 函数 描 ...
最新文章
- 模型可解释性技术概览
- C#判断年份是否为闰年
- 周鸿祎告诫员工:勿盲目把360看成巨头 不四处出击!
- 浅谈GPRS的几种应用方案
- python-带参数的装饰器
- apm飞控制作_传统直接转矩控制
- IEEE 802.1x 硬件参加的过程
- J2EE基础之EJB
- Junit - Eclipse 教程
- 手撸MIPS32——5、利用Vivado IP设计指令存储器和数据存储器
- 少年三国志服务器关闭注册,少年三国志2服务器关闭注册 怎么登陆到老区
- 基于DES加密的TCP聊天程序
- 浅析漫谈EOS之带宽
- 5.23 C语言练习(平均值计算:输入10个整数,求它们的平均值,并输出大于平均值的数据的个数。)
- 怀揣坚定与执着,踏实稳步向前
- maven-surefire-plugin
- 基于SSM的在线书城网站【附源码】
- 人工智能(crawler)—— 爬虫综合
- 一次挖矿入侵处理记录(2021.01.27)
- 计算一元二次方程-c++