我正在使用嵌套查询来获取特定半径内的记录。我想按距离对响应进行排序,并将距离作为响应参数之一传递。这是我使用的查询。
select ofr.offerId,ofr.outlet_id,ofr.offer_title,ofr.offer_icon,ofr.offer_description,ofr.CategoryId,ofr.offer_terms,
ofr.price_description,ofr.rating,ofr.isdeleted,ofr.minpoint_required,otl.shop_name,otl.shop_address,otl.shop_city,otl.shop_phone,otl.shop_icon,
otl.shop_latitude,otl.shop_longitude,otl.shop_country,otl.shop_zip,distance
from pp.offers as ofr
join pp.outlets as otl
where ofr.outlet_id = otl.shop_id and
MBRContains(GeomFromText(CONCAT('Polygon((',x1,' ', y1,',', x2,' ', y2,',', x3,' ', y3,',',x4,' ', y4,',', x1,' ', y1,'))')),otl.g)
and match(offer_title,offer_description) against(searchText)
order by (
SELECT glength(LineStringFromWKB(LineString(GeomFromText(astext(PointFromWKB(POINT(latitude,longitude)))), GeomFromText(astext(PointFromWKB(POINT(otl.shop_latitude,otl.shop_longitude)))))))*100
AS distance)
LIMIT 300
但是当试图执行这个我得到一个错误
未知场距
如何在 sql 查询的响应中返回内部查询中计算的距离?
谢谢