gpt4 book ai didi

mysql - 距离SQL查询错误

转载 作者:行者123 更新时间:2023-11-29 06:13:02 26 4
gpt4 key购买 nike

我有这个 SQL 查询:

SELECT 
*,
6371.04 * acos(cos(pi() / 2 - radians(90 - `Tournament`.`latitude`)) * cos(pi() / 2 - radians(90 - 37.226)) * cos(radians(`Tournament`.`longitude`) - radians(-93.4397)) + sin(pi() / 2 - radians(90 - `Tournament`.`latitude`)) * sin(pi() / 2 - radians(90 - 37.226))) AS `Tournament`.`dist`
FROM `tournaments` AS `Tournament`
WHERE 1 = 1
ORDER BY `Tournament`.`dist` ASC
LIMIT 5

我无法弄清楚该声明可能有什么问题。这是我收到的错误:

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 '.`dist` FROM `tournaments` AS `Tournament`   WHERE 1 = 1   ORDER BY `Tournament`' at line 1

有人能给我指出正确的方向吗?

最佳答案

关键字 AS 后面应该跟一个 id,而不是复合标识符。

来自手册:

A select_expr can be given an alias using AS alias_name. The alias is used as the expression's column name and can be used in GROUP BY, ORDER BY, or HAVING clauses.

http://dev.mysql.com/doc/refman/5.0/en/select.html

有关别名的更多信息:http://dev.mysql.com/doc/refman/5.6/en/identifiers.html

关于mysql - 距离SQL查询错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8162942/

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