我有這樣的SQL查詢:錯誤在距離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
任何人都可以指出我在正確的方向嗎?
我試着用http://www.dpriver.com/pp/sqlformat.htm格式化您的查詢,但可悲的是有很多的問題。請檢查鏈接。 –