MySQL根据根据经纬度查询距离

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013024120/article/details/53543325

MySQL根据根据经纬度查询距离


uu为用户信息表

#{longitude}为传入的经度,#{latitude}为传入的纬度

IFNULL(
    ROUND(
        ACOS(
            SIN((uu.latitude * PI()) / 180) * SIN((#{latitude} * PI()) / 180) 
            + 
            COS((uu.latitude * PI()) / 180) * COS((#{latitude} * PI()) / 180) 
            * 
            COS( (uu.longitude * PI()) / 180 - #{longitude} * PI() / 180 ) 
        ) * 6371,
        6
    )
    ,'暂无数据')
AS distance

猜你喜欢

转载自blog.csdn.net/u013024120/article/details/53543325