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)。靠近第一个,最后一个。
您如何更改此查询?感谢。
答案 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