drryyiuib43562604 2018-05-17 11:59
浏览 63
已采纳

MySQL#1064错误的位置查找器[关闭]

I'm trying to find the 10 entries that are closest to the user with the following search:

  $data_query = mysqli_query($db, "SELECT *
  111.045 * DEGREES(ACOS(COS(RADIANS(latpoint))
             * COS(RADIANS(latitude))
             * COS(RADIANS(longpoint) - RADIANS(longitude))
             + SIN(RADIANS(latpoint))
             * SIN(RADIANS(latitude)))) AS distance_in_km
 FROM merchants
 JOIN (
 SELECT  33.889676  AS latpoint,  151.193024 AS longpoint
) AS p ON 1=1
ORDER BY distance_in_km
LIMIT 15");

However I'm getting the following error:

#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 '111.045 * DEGREES(ACOS(COS(RADIANS(latpoint))
             * COS(RADIANS(la' at line 2

I tried changing SELECT * to SELECT latitude, longitude (with `` but Stack Overflow keeps messing up syntax) but it's not doing much.

I'm new to PHP and MySQL so I'm feeling pretty out of depth as to what could be going wrong here.

Cheers :)

  • 写回答

1条回答 默认 最新

  • doufan2541 2018-05-17 12:04
    关注

    If you want also select everything, then add comma after first *: SELECT *, 111.045 ...

    If not, then remove first *

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误