I have a table containing foodjoint data with their latitude and longitude.
I am using this query
$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 and $userLongitude is the users location.I want the distance to be compared in km. thnx in advance.
I want to display the foodjoint data under 3 km radious.
when I just running it doesn’t select any row.but with out this having condition it fetches all the records.
I found some code in a project of mine, but i’m not sure about the distance calculation.. You should improve your
JOINthough.. What are the tables joining on?