gpt4 book ai didi

php - mysql选择坐标错误

转载 作者:行者123 更新时间:2023-11-29 14:35:37 25 4
gpt4 key购买 nike

我试图从 mqysql 获取最接近的坐标,但语法出现错误!

$lat = 纬度;$long = 经度;

"SELECT * FROM `b_location` WHERE round(lat,3) LIKE $lat
AND round(long,2) LIKE $long order by acos(cos(radians($lat))*cos(radians(lat))*cos(radians(long)-
radians($long))+sin(radians($lat))*sin(radians(lat)) LIMIT 0,1"

错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0,1' at line 1

欢迎所有评论

最佳答案

公式最后一部分后缺少右括号

SELECT * 
FROM `b_location`
WHERE round(lat,3) LIKE $lat
AND round(long,2) LIKE $long
ORDER BY acos(cos(radians($lat)) *
cos(radians(lat)) *
cos(radians(long) - radians($long)) +
sin(radians($lat))*sin(radians(lat))
) LIMIT 0,1"

关于php - mysql选择坐标错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9126553/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com