Closed. This question is off-topic。它当前不接受答案。
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
2年前关闭。
我正在尝试通过以下搜索找到最接近用户的10个条目:
但是我收到以下错误:
我尝试将
我是
干杯:)
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
2年前关闭。
我正在尝试通过以下搜索找到最接近用户的10个条目:
$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");
但是我收到以下错误:
#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
我尝试将
SELECT *
更改为SELECT latitude, longitude
(使用``,但是Stack Overflow会弄乱语法),但是并没有做很多事情。我是
PHP
和MySQL
的新手,所以我对这里可能发生的问题感觉很不深入。干杯:)
最佳答案
如果还希望选择所有内容,请在第一个*
之后添加逗号:SELECT *, 111.045 ...
如果不是,则先删除*