gpt4 book ai didi

mysql - 从 latlang 计算距离 --MySQL 功能错误 (#1064)

转载 作者:行者123 更新时间:2023-11-29 00:16:23 25 4
gpt4 key购买 nike

我正在创建一个用于计算哈弗斯距离的函数,但我遇到了 Mysql 语法错误

1064 - 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 '' at line 8

DELIMITER $$
CREATE FUNCTION GEODIST (lat1 DOUBLE, lon1 DOUBLE, lat2 DOUBLE, lon2 DOUBLE)
RETURNS DOUBLE
DETERMINISTIC
BEGIN
DECLARE dist DOUBLE;
SET dist = round(acos(cos(radians(lat1)) * cos(radians(lon1)) * cos(radians(lat2)) * cos(radians(lon2)) + cos(radians(lat1)) * sin(radians(lon1)) * cos(radians(lat2)) * sin(radians(lon2)) + sin(radians(lat1)) * sin(radians(lat2))) * 6378.8, 1);
RETURN dist;
END$$

最佳答案

我已经在 Mysql 中试过你的代码,但同样没有用;但是当我添加一条额外的线时它起作用了,再次重置分隔符请检查

END$$
DELIMITER ;

如果这也出错了,我很抱歉......但对我来说效果很好

关于mysql - 从 latlang 计算距离 --MySQL 功能错误 (#1064),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22839534/

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