私がしたいのは、最も近い緯度と経度の都市を取得することです。 LAT、LNG、半径:
私の都市のテーブルには、3つのフィールドを持っている
私のクエリは次のようになります。Mysql order by byエイリアス
SELECT *
FROM cities
where st_distance_sphere(point(@lat, @lng), point(lat, lng)) <= area LIMIT 1
私の問題は、私は距離によってそれらを注文したいということです。 (st_distance_sphere(point(@lat, @lng), point(lat, lng))
)が距離を与える。
しかし、私はちょうどst_distance_sphere(point(@lat, @lng), point(lat, lng)) as distance
のエイリアスとORDER BY distance
と指定することはできません。
距離に基づいてどのように結果を注文しますか?