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
https://forums.phpfreaks.com/topic/212309-phpmysql-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.