MySQL Forums
Forum List  »  Newbie

Problem with a query
Posted by: Mike Lewis
Date: August 31, 2004 12:38PM

I'm very new to MySQL, so any help would be great.

I'm making a site which involves users being able to rate albums. The data on the albums is stored in table 'albums' with a keyfield 'albumID'. The votes are stored in table 'albumratings' with fields 'userID', 'albumID' and 'rating'. I want to run a query that produces a list of all album's details, along with the user's rating if there is one. The 'if there is one' bit is the problem.

I've tried:
SELECT * FROM albums,albumratings WHERE albums.albumID = albumratings.albumID AND albumratings.userID='$userID'

But that only displays the albums that have been rated by the user. I'd like to display all the albums, and the user's rating if he's rated it.

Thanks in advance,

Mike Lewis

Options: ReplyQuote

Written By
Problem with a query
August 31, 2004 12:38PM
September 01, 2004 12:32AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.