Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. SELECT `id`, `name`, `info`, `food`, `drinks`, `service`, `ambience`, `hygiene`, `recommend`, `best_menu`, `best_service`, `author`, `username`
  2. FROM `restaurants` RIGHT JOIN `rating` ON `rating`.`rid` IN (1,2,3);
  3.  
  4. SELECT `rid` as `id`, COUNT(*) as `count`, AVG(`food`+`drinks`+`service`+`ambience`+`hygiene`) as `average`, SUM(`food`) as `food`, SUM(`drinks`) as `drinks`, SUM(`service`) as `service`, SUM(`ambience`) as `ambience`, SUM(`hygiene`) as `hygiene`, concat(round(( SUM(`recommend`)/COUNT(*) * 100 ),2),'%') as `recommended`, `best_menu` as `best`, `best_service` as `service`, `voted` as `last vote`
  5. FROM `rating` WHERE `rid` IN (3,1,2) GROUP BY `rid` ORDER BY `best_menu`, `best_service`;
  6.  
  7. ratings_index
  8. (rating_id*,rating_title,rating_type(integer,string));
  9.  
  10. users
  11. (user_id*,username,email)
  12.  
  13. venues
  14. (venue_id,name,address)
  15.  
  16. user_integer_ratings
  17. (user_id*,venue_id*,rating_id*,rating)
  18.  
  19. user_string_ratings
  20. (user_id*,venue_id*,rating_id*,rating)
  21.  
  22. * = (component of) PRIMARY KEY
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement