select p.*,st_distance (
point (p.longitude, p.latitude ), point (:lng,:lat)
) * 111195 AS dist
from product p order by dist
按照距离排序商品距离,通过数据距离函数计算。高版本支持次函数。dist 计算出来单位为米。
本文介绍了一种使用SQL的ST_DISTANCE函数来计算并排序商品与指定经纬度之间距离的方法,适用于地理信息系统(GIS)相关的数据库操作。
select p.*,st_distance (
point (p.longitude, p.latitude ), point (:lng,:lat)
) * 111195 AS dist
from product p order by dist
按照距离排序商品距离,通过数据距离函数计算。高版本支持次函数。dist 计算出来单位为米。
2万+
4818

被折叠的 条评论
为什么被折叠?