緯度と経度を含む foodjoint データを含むテーブルがあります。
このクエリを使用しています
$q = "SELECT (
(ACOS(SIN( ".$userLatitude." * PI() / 180) * SIN(foodjoint_latitude * PI() / 180) + COS(".$userLongitude." * PI() / 180) * COS(foodjoint_longitude * PI() / 180) * COS((foodjoint_longitude - ".$longitude.") * PI() / 180)) * 180 / PI()) * 60 * 1.1515 * 1.609344) AS distance
, foodjoint_id
, foodjoint_name
, open_hours
, cont_no
, AVG(customer_ratings) AS rating
, address_line
, city
FROM provider_food_joints,customer_review HAVING distance <=3";
$userLatitude と $userLongitude はユーザーの場所です。距離を km で比較したいです。事前にthnx。半径 3 km 未満の foodjoint データを表示したいと考えています。
実行しただけでは、行は選択されませんが、この条件がなければ、すべてのレコードがフェッチされます。