0

这是我的查询:

select * 
  from (select *, 3956 * 2 * ASIN(SQRT(POWER(SIN(RADIANS(45.5200077 - lat)/ 2), 2) + COS(RADIANS(45.5200077)) * COS(RADIANS(lat)) * POWER(SIN(RADIANS(-122.6942014 - lng)/2),2))) AS distance 
          from stops 
      order by distance, route asc) as p 
group by route, dir 
order by distance asc 
   limit 10

这在命令行和 PHPMyAdmin 中运行良好。我正在使用Dbslayer通过我的 JavaScript 后端连接到 MySQL,请求返回 1064 错误。

这是编码的 DBSlayer 请求字符串:

http://localhost:9090/db ?{%22SQL%22:%22select%20*%20from%20%28select%20*,%203956%20*%202%20*%20ASIN%28SQRT%28POWER%28SIN% 28RADIANS%2845.5200077%20-%20lat%29/%202%29,%202%29%20+%20COS%28RADIANS%2845.5200077%29%29%20*%20COS%28RADIANS%28lat%29%29%20*% 20POWER%28SIN%28RADIANS%28-122.6942014%20-%20lng%29/2%29,2%29%29%29%20AS%20distance%20from%20%60stops%60%20order%20by%20%60distance%60 ,%20%60route%60%20asc%29%20as%20p%20group%20by%20%60route%60,%20%60dir%60%20order%20by%20%60distance%60%20asc%20limit%2010%22 }

和回应:

{"MYSQL_ERRNO" : 1064 , "MYSQL_ERROR" : "您的 SQL 语法有错误;请查看与您的 MySQL 服务器版本相对应的手册,了解在 '(RADIANS(45.5200077)) * COS(RADIANS( lat)) * POWER(SIN(RADIANS(-122.6942014 - lng' at line 1" , "SERVER" : "trimet"}

谢谢!

4

2 回答 2

0
...distance%60%20asc%20...

你是如何逃避 sql 的?看起来你错过了“路线”,所以上面写着“距离,asc”。看起来它从那里走下坡路。

于 2010-02-02T15:37:16.287 回答
0

您的问题的一个可能直接来源是 URL 编码。我看到加号运算符是按原样传输的。这很危险,因为在传统编码中 +曾经表示空格。http://www.faqs.org/rfcs/rfc1738

于 2010-02-02T15:52:00.700 回答