• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

MySQL query help

I have this query:
SELECT AVG( stars ) AS average,venueid FROM venuereview WHERE switch = '1' GROUP BY venueid ORDER BY average DESC

I need to somehow join the venuereview table  with the venue table and grab the 'venuename' from the venue table according to the 'venueid' ... can someone help me out?
0
lvollmer
Asked:
lvollmer
  • 2
1 Solution
 
nplibCommented:
SELECT AVG( r.stars ) AS average, r.venueid, v.venuename FROM venuereview r, venue v WHERE r.venueid = v.venueid and r.switch = '1' GROUP BY r.venueid ORDER BY r.average DESC
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
here we go:
SELECT AVG( r.stars ) AS average,r.venueid, v.venuename 
FROM venuereview r
JOIN venue v
  ON v.venueid = r.venueid
WHERE r.switch = '1' 
GROUP BY r.venueid
  , v.venuename
ORDER BY average DESC

Open in new window

0
 
lvollmerAuthor Commented:
sorry angel, I didn't see your response when I accepted points, otherwise would have split them.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
no problem!
glad you found your solution.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now