Welcome Guest, Not a member yet? Register   Sign In
{Solved} Combine 2 results into one.
#2

Hi,

You need to count the user_id with your group by
PHP Code:
public function get_posts() {
 
   $this->db->select('p.post_id, p.reply_id, p.user_id, u.username COUNT(p.user_id) AS total');
 
   $this->db->from('post as p');
 
   $this->db->join('user as u''u.user_id = p.user_id');
 
   $this->db->where('p.post_id'$this->input->get('post_id'));
 
   $this->db->or_where('p.reply_id'$this->input->get('post_id'));
 
   $this->db->group_by('p.user_id');
 
   $query $this->db->get();
 
   return $query->result_array();

A good decision is based on knowledge and not on numbers. - Plato

Reply


Messages In This Thread
RE: Combine 2 results into one. - by salain - 09-29-2016, 12:35 AM
RE: Combine 2 results into one. - by wolfgang1983 - 09-29-2016, 01:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB