I have this SQL query:
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
I can’t figure out what could be possibly wrong with that statement. Here’s the error I’m getting:
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
Could anyone point me in the right direction?
The keyword
ASis supposed to be followed by an id, not a compound identifier.From the manual:
http://dev.mysql.com/doc/refman/5.0/en/select.html
More on alias names: http://dev.mysql.com/doc/refman/5.6/en/identifiers.html