Solved

MySQL  query help

Posted on 2008-06-13
4
210 Views
Last Modified: 2013-12-13
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
Comment
Question by:lvollmer
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
nplib earned 500 total points
ID: 21780950
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
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21780971
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
 

Author Comment

by:lvollmer
ID: 21780991
sorry angel, I didn't see your response when I accepted points, otherwise would have split them.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21782444
no problem!
glad you found your solution.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now