我有一個項目表,每個項目都有經度和緯度值,可以計算距離。分配的查詢變量不被識別
我嘗試以下,但它返回:Unknown column distance in where clause
:
select (3959 * acos(cos(radians('53.993252'))
* cos(radians(latitude))
* cos(radians(longitude)
- radians('-0.432470'))
+ sin(radians('53.993252'))
* sin(radians(latitude)))) AS distance from items where distance < 1000
[使用列別名WHERE的MySQL條款(http://stackoverflow.com/questions/942571/using-column-alias-in-where-clause- of-mysql-query-produce-an-error) – valex