我如何在MySQL中订购此SELECT语句?

时间:2010-03-19 19:54:00

标签: mysql database select geolocation

cursor.execute("SELECT user_id FROM myapp_location WHERE\
       GLength(LineStringFromWKB(LineString(asbinary(utm), asbinary(PointFromWKB(point(%s, %s)))))) < %s"\
       ,(user_utm_easting, user_utm_northing, 500));

此查询选择与当前用户相距500英尺的用户。我如何在远处订购人? (glength)。靠近第一个,最后一个。

您如何更改此查询?感谢。

1 个答案:

答案 0 :(得分:1)

这是一种方式

SELECT user_id
     , GLength(LineStringFromWKB(LineString(asbinary(utm), asbinary(PointFromWKB(point(%s, %s)))))) as glength
  FROM myapp_location
HAVING glength < %s"
 ORDER BY glength desc