我正在使用嵌套查詢來獲取特定半徑內的記錄。我想按距離排序響應,並將距離作爲響應參數之一。這裏是我使用相同的查詢。如何將從內部查詢返回的值傳遞給外部查詢
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查詢?
感謝
哪裏有表距離字段? – Govind