Jump to content

php/mysql help


c_pattle

Recommended Posts

I have two tables.  The first is a list of articles where the primary key in the article number.  The second table is a list of ratings for those article where again the primary key is the article number (so I can link the two).  I'm trying to use a sql command to select all of the information in the articles table along with the average rating for that article. 

 

I have this so far which works however it only gives me the first article and no articles after that.  I think the problem is that the avg(ratings.score) is the average of ALL of the articles rather than for just one. 

 

SELECT AVG(ratings.score), articles.* FROM ratings, articles where ratings.article_number = articles.article_number;

 

Let me know if I didn't explain this well enough.  Thanks for any help. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.