2012-05-07 66 views
2

我有一個完美的最後一天運行謝赫Farooque回答查詢 Link of that question的Sql子查詢需要添加兩個查詢

現在我還有一個問題,我需要過濾那些foodjoint_id詳細哪都一樣cuisine_id下。 用戶要提交緯度長,cuisine_id我需要過濾那些FoodJoint

正如我告訴你,我已經通過,現在正在運行,我需要補充的美食過濾Lat Long網尋找食物聯合。

這是運行查詢是

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, 
(SELECT AVG(customer_ratings) 
FROM customer_review 
WHERE foodjoint_id=provider_food_joints.foodjoint_id) AS customer_rating 
FROM provider_food_joints 
HAVING distance < '3' ORDER BY distance 

,我已經添加了它:

SELECT foodjoint_id FROM menu_item WHERE cuisine_id=''.$userGivenCuisineId.'' 

我很抱歉地說,這個問題仍然沒有解決

+0

你能否更清楚你的問題 –

+0

請嘗試下面的答案。 –

回答

1
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, 
(select AVG(customer_ratings) from customer_review where 
foodjoint_id=provider_food_joints.foodjoint_id) as customer_rating 
FROM provider_food_joints 
where foodjoint_id in 
(SELECT foodjoint_id FROM menu_item WHERE cuisine_id='".$userGivenCuisineId."') 
HAVING distance < '3' ORDER BY distance 
+0

偉大的人偉大 – JANNURM