[eluser]darkhouse[/eluser]
I think all you're missing is the GROUP BY statement.
When you use an aggregate function like COUNT, you need to GROUP your results BY a common field. You mentioned that if you have 6 comments in the first blog post, you get 6 rows of that blog post... this is because you're joining the comments table without grouping anything. If you group the comments by blog_posts.id then it should give you exactly what you want. I've written it for you and added a total_comments column at the end:
Code:
$this->db->select('blog_posts.id,blog_posts.user_id, blog_posts.title, blog_posts.body, blog_posts.created, blog_posts.modified, users.username AS author, COUNT(blog_comments.id) AS total_comments');
$this->db->limit($num);
$this->db->join('users', 'users.id = blog_posts.user_id', 'left');
$this->db->join('blog_comments', 'blog_comments.post_id = blog_posts.id', 'left');
$this->db->group_by('blog_posts.id');
$this->db->order_by('blog_posts.created', 'DESC');
$query = $this->db->get('blog_posts');