2012-05-05 1 views
0

私は、緯度と経度のフードジョイントデータを含むテーブルを持っています。私はこのクエリは、3kmの放射能の下で適切なフードジョイントデータを表示しません。

$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を使用しています

は、ユーザーが距離をキロメートルで比較することにしたいlocation.Iです。 thnxは事前に。 私は食べ物のデータを3キロメートル下に表示したい。

私はそれを実行していないときに、すべてのレコードをフェッチする条件付きの行を選択しません。

答えて

0

私のプロジェクトでいくつかのコードが見つかりましたが、距離の計算についてはわかりません。あなたはJOINを改善する必要があります。結合しているテーブルは何ですか?

$q = "SELECT (
        (
         (
          ACOS(
           SIN(".$userLatitude." * PI()/180) * 
           SIN(foodjoint_latitude * PI()/180) + 

           COS(".$userLatitude." * PI()/180) * 
           COS(foodjoint_latitude * PI()/180) * 
           COS(
            (".$userLongitude." - foodjoint_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 < 4"; 
関連する問題