Heya, I have two tables.
The first one: articles, with the fields ArticleID, Title, Content.
The second one: comments, with the fields EntryID, ArticleID, Rank.
What I want to do is select all the articles from the table and order them by rank (which is, the sum of all "Rank" fields divided by the number of comments).
Example:
Table comments
EntryID, ArticleID, Rank
1, 1, 3
2, 2, 5
3, 2, 3
Table articles:
ArticleID, Title, Content
1, Test, Somecontent
2, Another test, Another content
Result: the article #2 would be first with a ranking of 4 while article 1 has a ranking of 3.
Basically what I need to do is sorting the table articles based on the ranking which is in the comments table
Any idea on how to do such query?
The first one: articles, with the fields ArticleID, Title, Content.
The second one: comments, with the fields EntryID, ArticleID, Rank.
What I want to do is select all the articles from the table and order them by rank (which is, the sum of all "Rank" fields divided by the number of comments).
Example:
Table comments
EntryID, ArticleID, Rank
1, 1, 3
2, 2, 5
3, 2, 3
Table articles:
ArticleID, Title, Content
1, Test, Somecontent
2, Another test, Another content
Result: the article #2 would be first with a ranking of 4 while article 1 has a ranking of 3.
Basically what I need to do is sorting the table articles based on the ranking which is in the comments table
Any idea on how to do such query?