I have two tables company,rate
Company has two columns-
- v_id
- company_name
user_ratings has three columns
- r_id
- v_id
- rate
In this rate v_id column,I have company_id (v_id) which has two different rating and when i count the ratings for one company every time i am getting only one. How to count the ratings for company.
function get_list() {
$this->db->select('company.company_name, COUNT(user_ratings.rate) as rate');
$this->db->from('company_details');
$this->db->join('user_ratings', 'company.v_id = user_ratings.v_id');
$this->db->group_by('company.company_name, rate');
$query = $this->db->get();
return $query->result();
}