该cont
表包含许多相同的记录userid
。我正在尝试从dist
列中为每个唯一用户 ID 选择最小距离值。
SELECT sec.*, r.contid, r.lng, r.lat, **math formula for distance** < $withinMiles AS dist
FROM cont r
JOIN s_cont s
ON r.userid = s.userid
WHERE (( **math formula for distance**))
ORDER BY dist ASC