SELECT city, (6372.797 * acos(cos(radians({$latitude})) * cos(radians(`latitude_range`)) * cos(radians(`longitude_range`) - radians({$longitude})) + sin(radians({$latitude})) * sin(radians(`latitude_range`)))) AS distance FROM cities WHERE active = 1 HAVING distance > 25 ORDER BY distance ASC
我喜欢能够抓取HAVING
距离大于 25KM 小于 50KM 的所有城市。我尝试输入的任何内容都会导致大于 25KM 的所有城市或错误。
如何添加HAVING distance > 25 AND distance <= 50
到我的 SQL 查询中?