Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.0k views
in Technique[技术] by (71.8m points)

MySQL 如何按照地理位置排序

展示列表需要有排序的业务,需要按照地理位置由近到远的排序,应该如何实现呢?

例如:
获取一张店铺的列表,其中包含地理位置的经纬度,sql应该怎么写才会比较高效?

shop表

字段描述
id
title标题
lng经度
lat维度

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

mysql 有 point 结构,用来存储经纬度,可以索引,结合 相关函数可以处理,不过用起来很纠结啊..

mongodb 考虑下. redis 也可以.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...