[eluser]derekmichaeljohnson[/eluser]
Works great!
Only problem is it doesn't show categories that don't have any users assigned to it yet. How can I get it to display empty categories with a zero?
EDIT:
Answered my own question... just made it a LEFT join. I also took the "users" table out of the query, as I don't really need user information for this particular usage. Here's my final code:
Code:
$this->db->select('cats.*, users_cats.cat_id, COUNT(users_cats.user_id) as user_count');
$this->db->from('cats');
$this->db->join('users_cats', 'users_cats.cat_id = cats.id','left');
$this->db->group_by("cats.id");
$data['cats'] = $this->db->get();