I have this query which is running perfectly
From this query I am selecting all restaurant 3 KM from my location this is my 1st table.
SELECT foodjoint_id,foodjoint_name,open_hours,cont_no,address_line,city ( 3959 * acos( cos( radians('".$userLatitude."') ) * cos( radians( foodjoint_latitude) ) * cos( radians( foodjoint_longitude) - radians('".$userLongitude."') ) + sin( radians('".$userLatitude."') ) * sin( radians( foodjoint_latitude) ) ) ) AS distance
FROM provider_food_joints
HAVING distance < '3' ORDER BY distance LIMIT 0 , 20
But I need to select the AVG rating from those food joint which are with in this 3Km.
The query is also running perfectly:
select AVG(customer_ratings) from customer_review where foodjoint_id=".$foodjoint_id
but I need to add this two query through which I can select all those food joint and their rating AVG.
Just place the subquery and you will get your result: