Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # working right - gives 5 result
- SELECT R.Title FROM Restaurant R, RestaurantCategory RC, RestaurantOptions RS
- WHERE R.RestaurantCategoryID = RC.RestaurantCategoryID
- AND R.RestaurantID = RS.RestaurantID
- AND RC.RestaurantCategoryParentID = 185
- AND RS.RestaurantCategoryOptionsID IN(11,2) GROUP BY R.RestaurantID HAVING COUNT(DISTINCT RS.RestaurantCategoryOptionsID) = 2
- ORDER BY R.Title DESC;
- # working wrong - gives me about 30 different restaurants... should give 5 as upper statement
- SELECT RC.Title AS Title, RC.RestaurantCategoryID AS RestaurantCategoryID,
- COUNT(DISTINCT R.RestaurantID) AS Total FROM Restaurant R, RestaurantCategory RC, RestaurantOptions RS
- WHERE R.RestaurantCategoryID = RC.RestaurantCategoryID AND R.RestaurantID = RS.RestaurantID
- AND RC.RestaurantCategoryParentID = 185 AND R.Status = 1
- AND RS.RestaurantCategoryOptionsID IN(11,2)
- GROUP BY RC.RestaurantCategoryID
- HAVING COUNT(DISTINCT RS.RestaurantCategoryOptionsID) = 2 ORDER BY RC.Title ASC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement