[eluser]A.M.F[/eluser]
hello people
i'm having a problam. i have to tabels in my database: one for articles, and another for article's comments.
in the comments table one of my fields is "article_id" which containes the article's id of the comment.
i want to show the whole articles in one page and next to each article the amount of comments that the articles has.
for example:
"5 tips for games - number of comments: 3"
this is what i tried to:
Code:
$this->db->from('games, comments');
$this->db->select('games.*, comments.*, COUNT(comments.cmnt_itemid) as votes');
$this->db->orderby('ga_id', 'desc');
$this->db->limit($config['per_page'], $start_at);
$data['games'] = $this->db->get();
but this is the error that i get:
Quote:Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
SELECT games.*, comments.*, COUNT(comments.cmnt_itemid) as votes FROM games, comments ORDER BY ga_id desc LIMIT 12
what can i do?
thank u