Solved

MySQL  query help

Posted on 2008-06-13
4
209 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

757 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

20 Experts available now in Live!

Get 1:1 Help Now